Add :delm[arks] {marks} command to delete vim marks (#31140)

Release Notes:

- Implements `:delm[arks] {marks}` specified
[here](https://vimhelp.org/motion.txt.html#%3Adelmarks)
- Adds `ArgumentRequired` action for vim commands that require arguments

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
AidanV 2025-06-02 12:18:28 -07:00 committed by GitHub
parent 864767ad35
commit 9d5fb3c3f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 258 additions and 4 deletions

View file

@ -279,6 +279,10 @@ impl Vim {
if name == "`" {
name = "'".to_string();
}
if matches!(&name[..], "-" | " ") {
// Not allowed marks
return;
}
let entity_id = workspace.entity_id();
Vim::update_globals(cx, |vim_globals, cx| {
let Some(marks_state) = vim_globals.marks.get(&entity_id) else {
@ -326,6 +330,30 @@ impl Vim {
.update(cx, |ms, cx| ms.get_mark(name, editor.buffer(), cx))
})
}
pub fn delete_mark(
&self,
name: String,
editor: &mut Editor,
window: &mut Window,
cx: &mut App,
) {
let Some(workspace) = self.workspace(window) else {
return;
};
if name == "`" || name == "'" {
return;
}
let entity_id = workspace.entity_id();
Vim::update_globals(cx, |vim_globals, cx| {
let Some(marks_state) = vim_globals.marks.get(&entity_id) else {
return;
};
marks_state.update(cx, |ms, cx| {
ms.delete_mark(name.clone(), editor.buffer(), cx);
});
});
}
}
pub fn jump_motion(