diff options
author | Blaž Hrastnik | 2021-05-08 09:25:19 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-05-08 09:25:19 +0000 |
commit | ed827e993f0a0ef8d48eb54cf314facbda15a2ba (patch) | |
tree | 4608229f9f52b5d7c7cce3903d471695b2451040 /helix-term | |
parent | caf434992563cbdedeccb5574af16091e987f365 (diff) |
Fix jumplist jumps, keep the selection on vsplit.
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 59425670..fe160ab8 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2167,6 +2167,7 @@ pub fn jump_forward(cx: &mut Context) { if let Some((id, selection)) = view.jumps.forward(count) { view.doc = *id; let selection = selection.clone(); + let (view, doc) = cx.current(); // refetch doc doc.set_selection(view.id, selection); align_view(doc, view, Align::Center); @@ -2179,7 +2180,9 @@ pub fn jump_backward(cx: &mut Context) { if let Some((id, selection)) = view.jumps.backward(count) { view.doc = *id; - doc.set_selection(view.id, selection.clone()); + let selection = selection.clone(); + let (view, doc) = cx.current(); // refetch doc + doc.set_selection(view.id, selection); align_view(doc, view, Align::Center); }; @@ -2189,9 +2192,17 @@ pub fn jump_backward(cx: &mut Context) { pub fn vsplit(cx: &mut Context) { use helix_view::editor::Action; - let id = cx.doc().id(); + let (view, doc) = cx.current(); + let id = doc.id(); + let selection = doc.selection(view.id).clone(); + let first_line = view.first_line; cx.editor.switch(id, Action::VerticalSplit); + + // match the selection in the previous view + let (view, doc) = cx.current(); + view.first_line = first_line; + doc.set_selection(view.id, selection); } pub fn space_mode(cx: &mut Context) { |