Skip to content

Commit

Permalink
fix: View needs to retain the original scroll offset on split
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Sep 5, 2022
1 parent 9c3c6a1 commit 1acdfaa
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4142,12 +4142,16 @@ fn split(cx: &mut Context, action: Action) {
let (view, doc) = current!(cx.editor);
let id = doc.id();
let selection = doc.selection(view.id).clone();
let offset = view.offset;

cx.editor.switch(id, action);

// match the selection in the previous view
let (view, doc) = current!(cx.editor);
doc.set_selection(view.id, selection);
// match the view scroll offset (switch doesn't handle this fully
// since the selection is only matched after the split)
view.offset = offset;
}

fn hsplit(cx: &mut Context) {
Expand Down

0 comments on commit 1acdfaa

Please sign in to comment.