aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-09-05 02:57:41 +0000
committerBlaž Hrastnik2022-09-05 02:58:00 +0000
commit1acdfaa073327cb52c27186235d69ac095ab468d (patch)
tree1f2d5cb5edcf56aba80175b004308cee6d92c82d
parent9c3c6a1c22db065512c5563e9ed1c9dca869c886 (diff)
fix: View needs to retain the original scroll offset on split
-rw-r--r--helix-term/src/commands.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index babfb2c8..e869446e 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -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) {