Fix up assertion errors in set_eq and visual tests

This commit is contained in:
Keith Simmons 2022-05-10 11:09:49 -07:00
parent 37c921f972
commit 3f1640a9a0
2 changed files with 13 additions and 5 deletions

View File

@ -49,12 +49,12 @@ macro_rules! assert_set_eq {
let left = $left;
let right = $right;
match set_eq!(left, right) {
match set_eq!(&left, &right) {
Err(SetEqError::LeftMissing(missing)) => {
panic!("assertion failed: `(left == right)`\n left: {:?}\nright: {:?}\nright does not contain {:?}", left, right, missing);
panic!("assertion failed: `(left == right)`\n left: {:?}\nright: {:?}\nright does not contain {:?}", &left, &right, &missing);
},
Err(SetEqError::RightMissing(missing)) => {
panic!("assertion failed: `(left == right)`\n left: {:?}\nright: {:?}\nleft does not contain {:?}", left, right, missing);
panic!("assertion failed: `(left == right)`\n left: {:?}\nright: {:?}\nleft does not contain {:?}", &left, &right, &missing);
},
_ => {}
}

View File

@ -56,6 +56,7 @@ pub fn change(_: &mut Workspace, _: &VisualChange, cx: &mut ViewContext<Workspac
pub fn delete(_: &mut Workspace, _: &VisualDelete, cx: &mut ViewContext<Workspace>) {
Vim::update(cx, |vim, cx| {
vim.switch_mode(Mode::Normal, cx);
vim.update_active_editor(cx, |editor, cx| {
editor.set_clip_at_line_ends(false, cx);
editor.move_selections(cx, |map, selection| {
@ -67,8 +68,15 @@ pub fn delete(_: &mut Workspace, _: &VisualDelete, cx: &mut ViewContext<Workspac
}
});
editor.insert("", cx);
// Fixup cursor position after the deletion
editor.set_clip_at_line_ends(true, cx);
editor.move_selections(cx, |map, selection| {
let mut cursor = selection.head();
cursor = map.clip_point(cursor, Bias::Left);
selection.collapse_to(cursor, selection.goal)
});
});
vim.switch_mode(Mode::Normal, cx);
});
}
@ -213,7 +221,7 @@ mod test {
#[gpui::test]
async fn test_visual_change(cx: &mut gpui::TestAppContext) {
let cx = VimTestContext::new(cx, true).await;
let mut cx = cx.binding(["v", "w", "x"]).mode_after(Mode::Insert);
let mut cx = cx.binding(["v", "w", "c"]).mode_after(Mode::Insert);
cx.assert("The quick |brown", "The quick |");
let mut cx = cx.binding(["v", "w", "j", "c"]).mode_after(Mode::Insert);
cx.assert(