From dbdca8f33f3ab34ed7dec069242ea561aa2e7a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Mon, 5 Sep 2022 11:57:41 +0900 Subject: [PATCH] fix: View needs to retain the original scroll offset on split --- helix-term/src/commands.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index babfb2c824e8a..e869446ef6167 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) {