on master help sign in
Fix panic when reloading a shrunk file (#2506)

* fix panic when reloading a shrunk file * linting * use scrolloff

commit5c864922d88a88898ab7525f8ebd33f8f5096c59 authorLeoi Hung Kin <leoihungkin@outlook.com> dateSun 22 May 2022, 09:24 (4 years ago) parent8df8ff2
1 file changed+4−1
helix-term/src/commands/typed.rs+4−1
helix-term/src/commands/typed.rs+4−1
@@ -781,8 +781,11 @@ fn reload(
781781 _args: &[Cow<str>],
782782 _event: PromptEvent,
783783) -> anyhow::Result<()> {
784+ let scrolloff = cx.editor.config().scrolloff;
784785 let (view, doc) = current!(cx.editor);
785− doc.reload(view.id)
786+ doc.reload(view.id).map(|_| {
787+ view.ensure_cursor_in_view(doc, scrolloff);
788+ })
786789}
787790
788791fn tree_sitter_scopes(