diff options
author | Michael Davis | 2022-08-31 01:45:47 +0000 |
---|---|---|
committer | GitHub | 2022-08-31 01:45:47 +0000 |
commit | 701cea54d280786d5762396c5d2655cba5b508b4 (patch) | |
tree | 57225db87c75f8d4d6d6c8cf3d1747c4af4a6c95 /helix-term/src | |
parent | 404db2ebee477a9bfdb76e89ebf48adac9c1a57c (diff) |
jumplist: Add documents to view history (#3593)
This change adds documents to the view's document history Vec.
(This is used by `ga` for example to access the last buffer.)
Previously, a sequence like so would have confusing behavior:
1. Open file A: any document with an active language server
2. Find some definition that lives in another file - file B - with `gd`
3. Jump back in the jumplist with `C-o` to file A
4. Use `ga` intending to switch back to file B
The behavior prior to this change was that `ga` would switch to file
A: you could not use `ga` to switch to file B.
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/commands.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index cb5460af..5bce6ca6 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -4060,13 +4060,18 @@ fn match_brackets(cx: &mut Context) { fn jump_forward(cx: &mut Context) { let count = cx.count(); let view = view_mut!(cx.editor); + let doc_id = view.doc; if let Some((id, selection)) = view.jumps.forward(count) { view.doc = *id; let selection = selection.clone(); let (view, doc) = current!(cx.editor); // refetch doc - doc.set_selection(view.id, selection); + if doc.id() != doc_id { + view.add_to_history(doc_id); + } + + doc.set_selection(view.id, selection); align_view(doc, view, Align::Center); }; } @@ -4074,13 +4079,18 @@ fn jump_forward(cx: &mut Context) { fn jump_backward(cx: &mut Context) { let count = cx.count(); let (view, doc) = current!(cx.editor); + let doc_id = doc.id(); if let Some((id, selection)) = view.jumps.backward(view.id, doc, count) { view.doc = *id; let selection = selection.clone(); let (view, doc) = current!(cx.editor); // refetch doc - doc.set_selection(view.id, selection); + if doc.id() != doc_id { + view.add_to_history(doc_id); + } + + doc.set_selection(view.id, selection); align_view(doc, view, Align::Center); }; } |