mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-09 21:26:14 +03:00
Fix up assertion errors in set_eq and visual tests
This commit is contained in:
parent
37c921f972
commit
3f1640a9a0
@ -49,12 +49,12 @@ macro_rules! assert_set_eq {
|
|||||||
let left = $left;
|
let left = $left;
|
||||||
let right = $right;
|
let right = $right;
|
||||||
|
|
||||||
match set_eq!(left, right) {
|
match set_eq!(&left, &right) {
|
||||||
Err(SetEqError::LeftMissing(missing)) => {
|
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)) => {
|
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);
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ pub fn change(_: &mut Workspace, _: &VisualChange, cx: &mut ViewContext<Workspac
|
|||||||
|
|
||||||
pub fn delete(_: &mut Workspace, _: &VisualDelete, cx: &mut ViewContext<Workspace>) {
|
pub fn delete(_: &mut Workspace, _: &VisualDelete, cx: &mut ViewContext<Workspace>) {
|
||||||
Vim::update(cx, |vim, cx| {
|
Vim::update(cx, |vim, cx| {
|
||||||
|
vim.switch_mode(Mode::Normal, cx);
|
||||||
vim.update_active_editor(cx, |editor, cx| {
|
vim.update_active_editor(cx, |editor, cx| {
|
||||||
editor.set_clip_at_line_ends(false, cx);
|
editor.set_clip_at_line_ends(false, cx);
|
||||||
editor.move_selections(cx, |map, selection| {
|
editor.move_selections(cx, |map, selection| {
|
||||||
@ -67,8 +68,15 @@ pub fn delete(_: &mut Workspace, _: &VisualDelete, cx: &mut ViewContext<Workspac
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
editor.insert("", cx);
|
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]
|
#[gpui::test]
|
||||||
async fn test_visual_change(cx: &mut gpui::TestAppContext) {
|
async fn test_visual_change(cx: &mut gpui::TestAppContext) {
|
||||||
let cx = VimTestContext::new(cx, true).await;
|
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 |");
|
cx.assert("The quick |brown", "The quick |");
|
||||||
let mut cx = cx.binding(["v", "w", "j", "c"]).mode_after(Mode::Insert);
|
let mut cx = cx.binding(["v", "w", "j", "c"]).mode_after(Mode::Insert);
|
||||||
cx.assert(
|
cx.assert(
|
||||||
|
Loading…
Reference in New Issue
Block a user