From 15c5692685df67971c6d2567309f213154db0c97 Mon Sep 17 00:00:00 2001 From: Leoi Hung Kin Date: Sun, 22 May 2022 09:24:32 +0800 Subject: [PATCH] Fix panic when reloading a shrunk file (#2506) * fix panic when reloading a shrunk file * linting * use scrolloff --- helix-term/src/commands/typed.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 74ab73bef8f55..5121eaa183a00 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -781,8 +781,11 @@ fn reload( _args: &[Cow], _event: PromptEvent, ) -> anyhow::Result<()> { + let scrolloff = cx.editor.config().scrolloff; let (view, doc) = current!(cx.editor); - doc.reload(view.id) + doc.reload(view.id).map(|_| { + view.ensure_cursor_in_view(doc, scrolloff); + }) } fn tree_sitter_scopes(