Add Helix jump list navigation#44661
Conversation
Implement Helix-style jump list for position history navigation with Ctrl-s (save), Ctrl-o (backward), and Ctrl-i (forward) keybindings. The jump list maintains up to 30 entries matching Helix's behavior: - Prevents consecutive duplicate entries - Truncates forward history when pushing from middle of list - Auto-saves current position when jumping backward from present - Supports cross-buffer navigation Closes zed-industries#41580
|
We require contributors to sign our Contributor License Agreement, and we don't have @ShaiKKO on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
…mp list - Store full selection ranges (start+end anchors) instead of just cursor heads - Add JumpLocation enum: Buffer(EntityId) for open files, Path(Arc<Path>) for closed - Add JumpSelections enum: Anchors for open buffers, Points for closed files - Hook buffer release via cx.observe_release() to convert entries when files close - Add helix_jump_to_path() to reopen closed files and restore selections - Track watched buffers in VimGlobals to manage lifecycle subscriptions This enables jumping back to positions in files that have been closed - the jump list preserves the file path and selection points, reopening the file when navigating to that entry.
cbd9f83 to
41170c1
Compare
|
After further review I identified 3 areas that I address in the PR below (should have caught these before submission, so apologies for that, hope this saves you some time on the backend).
( This enables jumping back to positions in files that have been closed and is NOT a default helix feature, and is noted as an issue in helix itself, I opted to implement it here and see what people thought on the matter) - the jump list preserves the file path and selection points and reopens the file. )
|
|
Can you fix the clippy errors? I won't be able to review the changes until the CI is green. |
|
@jasonwilliams got busy with some other areas and this got lost in my lists.
IE -> saves and restores full multi selections (not just cursor positions), manual + automatic save, reopening of closed files in multi-buffer, duplicate skipping, forward truncation, capacity limits, etc. reusing zeds jump list effectively removes all of the functionality that matters/has anything to do with Helix. @kubkon I will fix these CI issues by tomorrow so you can review, I also think the PR linked to this regarding #44530 is non related. |
This PR implements Helix's jump list feature, addressing issue #41580 and continuing the work discussed in #33580.
The jump list is one of Helix's core navigation features that lets users save cursor positions and quickly jump between them. I've implemented the three commands that make up this feature:
Ctrl-sto save the current selection,Ctrl-oto jump backward through saved positions, andCtrl-ito jump forward.I followed the existing patterns in the vim crate pretty closely here. The
JumpListstruct lives in a newjump_list.rsmodule underhelix/, and the global state is stored inVimGlobalsalongside marks and registers. This felt like the natural home for it since the jump list persists across buffer switches, similar to how marks work.The data structure mirrors Helix's implementation - a
VecDequewith a capacity of 30 entries and a cursor tracking where we are in the history. Each entry stores a buffer ID and the selection anchors, which means positions stay valid even as the document is edited.When you save a position that's identical to the last one, we skip it to avoid cluttering the list with duplicates. If you're in the middle of the history and save a new position, everything "ahead" of you gets truncated - this matches how most undo systems work and feels intuitive in practice.
The trickiest bit was handling the "jump from present" case. When you're at the end of the list (haven't jumped yet) and hit
Ctrl-o, Helix automatically saves your current position before jumping. This way you can always get back to where you started. I've replicated this behavior.Cross-buffer jumps work by looking up the target buffer in the workspace and activating it before restoring the selection. The anchors handle position validity automatically since they're tied to the buffer's edit history.
I've added unit tests for the
JumpListdata structure covering the basic operations, capacity limits, duplicate prevention, and the forward-history truncation behavior. There are also integration tests that exercise the actual keybindings in aVimTestContextwith Helix mode enabled.Release Notes
Ctrl-sto save position,Ctrl-oto jump backward,Ctrl-ito jump forward (vim mode with Helix keybindings enabled)Related: #41580, #33580