From b6c5c7871ee67935d52138f9df6c90b13cf055b9 Mon Sep 17 00:00:00 2001 From: Kay Simmons Date: Fri, 4 Nov 2022 15:21:29 -0700 Subject: [PATCH] Addresses issue where left motion in vim mode would clip in the wrong direction --- crates/vim/src/motion.rs | 2 +- crates/vim/src/normal.rs | 6 ++++++ crates/vim/test_data/test_h_through_unicode.json | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 crates/vim/test_data/test_h_through_unicode.json diff --git a/crates/vim/src/motion.rs b/crates/vim/src/motion.rs index de621c5476..5aa1df6dd8 100644 --- a/crates/vim/src/motion.rs +++ b/crates/vim/src/motion.rs @@ -266,7 +266,7 @@ impl Motion { fn left(map: &DisplaySnapshot, mut point: DisplayPoint, times: usize) -> DisplayPoint { for _ in 0..times { *point.column_mut() = point.column().saturating_sub(1); - point = map.clip_point(point, Bias::Right); + point = map.clip_point(point, Bias::Left); if point.column() == 0 { break; } diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index 531f52bf9a..67b58ac585 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -851,4 +851,10 @@ mod test { .await; } } + + #[gpui::test] + async fn test_h_through_unicode(cx: &mut gpui::TestAppContext) { + let mut cx = NeovimBackedTestContext::new(cx).await.binding(["h"]); + cx.assert_all("Testˇ├ˇ──ˇ┐ˇTest").await; + } } diff --git a/crates/vim/test_data/test_h_through_unicode.json b/crates/vim/test_data/test_h_through_unicode.json new file mode 100644 index 0000000000..86d6d0832d --- /dev/null +++ b/crates/vim/test_data/test_h_through_unicode.json @@ -0,0 +1 @@ +[{"Text":"Test├──┐Test"},{"Mode":"Normal"},{"Selection":{"start":[0,3],"end":[0,3]}},{"Mode":"Normal"},{"Text":"Test├──┐Test"},{"Mode":"Normal"},{"Selection":{"start":[0,4],"end":[0,4]}},{"Mode":"Normal"},{"Text":"Test├──┐Test"},{"Mode":"Normal"},{"Selection":{"start":[0,10],"end":[0,10]}},{"Mode":"Normal"},{"Text":"Test├──┐Test"},{"Mode":"Normal"},{"Selection":{"start":[0,13],"end":[0,13]}},{"Mode":"Normal"}] \ No newline at end of file