From 5c864922d88a88898ab7525f8ebd33f8f5096c59 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 74ab73be..5121eaa1 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(