vim: Add motion support for toggle comments (#14919)
### Summary This PR adds support for count and object motions to the toggle comments action in Vim mode. The relevant issue is [#14337](https://github.com/zed-industries/zed/issues/14337). For example, `2 g c j` will toggle comments three lines downward. `g c g g` will toggle comments from the current cursor position up to the start of the file. Notably missing from this PR are `g c b` (toggle comments for the current block) as well as `g c p` (toggle comments for the current paragraph). These seem to be non-standard. The new module `normal/toggle_comments.rs` has been copied almost verbatim from `normal/indent.rs`. Maybe that ought to be abstracted over but I feel I lack the overview. Release Notes: - vim: Added support for count and object motion to the toggle comments action ([#14337](https://github.com/zed-industries/zed/issues/14337)).
This commit is contained in:
parent
eb210ca248
commit
1fae99a7c4
6 changed files with 96 additions and 2 deletions
|
@ -1268,6 +1268,29 @@ async fn test_toggle_comments(cx: &mut gpui::TestAppContext) {
|
|||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
|
||||
// works with count
|
||||
cx.simulate_keystrokes("g c 2 j");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
// // ˇone
|
||||
// two
|
||||
// three
|
||||
"},
|
||||
Mode::Normal,
|
||||
);
|
||||
|
||||
// works with motion object
|
||||
cx.simulate_keystrokes("shift-g");
|
||||
cx.simulate_keystrokes("g c g g");
|
||||
cx.assert_state(
|
||||
indoc! {"
|
||||
// one
|
||||
two
|
||||
three
|
||||
ˇ"},
|
||||
Mode::Normal,
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue