Unnamed repository; edit this file 'description' to name the repository.
Fix panic when reloading a shrunk file (#2506)
* fix panic when reloading a shrunk file * linting * use scrolloff
Leoi Hung Kin 2022-05-22
parent 8df8ff2 · commit 5c86492
-rw-r--r--helix-term/src/commands/typed.rs5
1 files changed, 4 insertions, 1 deletions
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<str>],
_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(