[WIP] editor: Implement next/prev reference (#41078)

Co-authored-by: Cole <cole@zed.dev>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Cameron Mcloughlin
2025-10-28 20:41:44 +00:00
committed by GitHub
co-authored by Cole Conrad Irwin
parent b75736568b
commit 5e7927f628
7 changed files with 313 additions and 0 deletions
+34
View File
@@ -100,6 +100,10 @@ actions!(
GoToTab,
/// Go to previous tab page (with count support).
GoToPreviousTab,
/// Go to tab page (with count support).
GoToPreviousReference,
/// Go to previous tab page (with count support).
GoToNextReference,
]
);
@@ -202,6 +206,36 @@ pub(crate) fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
vim.join_lines_impl(false, window, cx);
});
Vim::action(editor, cx, |vim, _: &GoToPreviousReference, window, cx| {
let count = Vim::take_count(cx);
vim.update_editor(cx, |_, editor, cx| {
let task = editor.go_to_reference_before_or_after_position(
editor::Direction::Prev,
count.unwrap_or(1),
window,
cx,
);
if let Some(task) = task {
task.detach_and_log_err(cx);
};
});
});
Vim::action(editor, cx, |vim, _: &GoToNextReference, window, cx| {
let count = Vim::take_count(cx);
vim.update_editor(cx, |_, editor, cx| {
let task = editor.go_to_reference_before_or_after_position(
editor::Direction::Next,
count.unwrap_or(1),
window,
cx,
);
if let Some(task) = task {
task.detach_and_log_err(cx);
};
});
});
Vim::action(editor, cx, |vim, _: &Undo, window, cx| {
let times = Vim::take_count(cx);
Vim::take_forced_motion(cx);