vim: Add global marks (#25702)

Closes https://github.com/zed-industries/zed/issues/13111

Release Notes:

- vim: Added global marks `'[A-Z]`
- vim: Added persistence for global (and local) marks. When re-opening
the same workspace your previous marks will be available.

---------

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
AidanV 2025-03-14 22:58:34 -07:00 committed by GitHub
parent 148131786f
commit 265caed15e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 982 additions and 281 deletions

View file

@ -37,7 +37,7 @@ use crate::{
JoinLines,
},
object::Object,
state::Mode,
state::{Mark, Mode},
visual::VisualDeleteLine,
ToggleRegistersView, Vim,
};
@ -284,6 +284,7 @@ pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
true,
true,
vec![Point::new(range.start.0, 0)..end],
window,
cx,
)
}
@ -594,9 +595,14 @@ impl Position {
}
}
Position::Mark { name, offset } => {
let Some(mark) = vim.marks.get(&name.to_string()).and_then(|vec| vec.last()) else {
let Some(Mark::Local(anchors)) =
vim.get_mark(&name.to_string(), editor, window, cx)
else {
return Err(anyhow!("mark {} not set", name));
};
let Some(mark) = anchors.last() else {
return Err(anyhow!("mark {} contains empty anchors", name));
};
mark.to_point(&snapshot.buffer_snapshot)
.row
.saturating_add_signed(*offset)