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
|
@ -9,6 +9,7 @@ pub(crate) mod repeat;
|
|||
mod scroll;
|
||||
pub(crate) mod search;
|
||||
pub mod substitute;
|
||||
mod toggle_comments;
|
||||
pub(crate) mod yank;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
@ -39,6 +40,7 @@ use self::{
|
|||
change::{change_motion, change_object},
|
||||
delete::{delete_motion, delete_object},
|
||||
indent::{indent_motion, indent_object, IndentDirection},
|
||||
toggle_comments::{toggle_comments_motion, toggle_comments_object},
|
||||
yank::{yank_motion, yank_object},
|
||||
};
|
||||
|
||||
|
@ -237,6 +239,7 @@ pub fn normal_motion(
|
|||
Some(Operator::OppositeCase) => {
|
||||
change_case_motion(vim, motion, times, CaseTarget::OppositeCase, cx)
|
||||
}
|
||||
Some(Operator::ToggleComments) => toggle_comments_motion(vim, motion, times, cx),
|
||||
Some(operator) => {
|
||||
// Can't do anything for text objects, Ignoring
|
||||
error!("Unexpected normal mode motion operator: {:?}", operator)
|
||||
|
@ -273,6 +276,7 @@ pub fn normal_object(object: Object, cx: &mut WindowContext) {
|
|||
target: Some(SurroundsType::Object(object)),
|
||||
});
|
||||
}
|
||||
Some(Operator::ToggleComments) => toggle_comments_object(vim, object, around, cx),
|
||||
_ => {
|
||||
// Can't do anything for namespace operators. Ignoring
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue