From daf09fa532e6af93f9efb7e306c5c2eee81b3173 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Mon, 3 Feb 2025 21:40:45 -0600 Subject: [PATCH] Fix issue where changing the case of a vim object would be clipped at the end of the line (#24163) Co-authored-by: Conrad Irwin Closes #24124 Release Notes: - Fixed an issue in vim mode where changing the case of an object at the end of the line would not change the case of the last character in the object Co-authored-by: Conrad Irwin --- crates/vim/src/normal/case.rs | 11 +++++++++++ .../vim/test_data/test_change_case_motion_object.json | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 crates/vim/test_data/test_change_case_motion_object.json diff --git a/crates/vim/src/normal/case.rs b/crates/vim/src/normal/case.rs index fdebaac261..778003784a 100644 --- a/crates/vim/src/normal/case.rs +++ b/crates/vim/src/normal/case.rs @@ -73,6 +73,7 @@ impl Vim { self.stop_recording(cx); self.update_editor(window, cx, |_, editor, window, cx| { editor.transact(window, cx, |editor, window, cx| { + editor.set_clip_at_line_ends(false, cx); let mut original_positions: HashMap<_, _> = Default::default(); editor.change_selections(None, window, cx, |s| { s.move_with(|map, selection| { @@ -100,6 +101,7 @@ impl Vim { selection.collapse_to(anchor.to_display_point(map), SelectionGoal::None); }); }); + editor.set_clip_at_line_ends(true, cx); }); }); } @@ -306,4 +308,13 @@ mod test { cx.simulate_shared_keystrokes("g shift-u $").await; cx.shared_state().await.assert_eq("ˇABC DEF"); } + + #[gpui::test] + async fn test_change_case_motion_object(cx: &mut gpui::TestAppContext) { + let mut cx = NeovimBackedTestContext::new(cx).await; + + cx.set_shared_state("abc dˇef\n").await; + cx.simulate_shared_keystrokes("g shift-u i w").await; + cx.shared_state().await.assert_eq("abc ˇDEF\n"); + } } diff --git a/crates/vim/test_data/test_change_case_motion_object.json b/crates/vim/test_data/test_change_case_motion_object.json new file mode 100644 index 0000000000..b2157975bd --- /dev/null +++ b/crates/vim/test_data/test_change_case_motion_object.json @@ -0,0 +1,6 @@ +{"Put":{"state":"abc dˇef\n"}} +{"Key":"g"} +{"Key":"shift-u"} +{"Key":"i"} +{"Key":"w"} +{"Get":{"state":"abc ˇDEF\n","mode":"Normal"}}