Fix panic when reloading a shrunk file (#2506)

* fix panic when reloading a shrunk file

* linting

* use scrolloff
This commit is contained in:
Leoi Hung Kin 2022-05-22 09:24:32 +08:00 committed by GitHub
parent 8df8ff27c2
commit 5c864922d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -781,8 +781,11 @@ fn reload(
_args: &[Cow<str>], _args: &[Cow<str>],
_event: PromptEvent, _event: PromptEvent,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
let scrolloff = cx.editor.config().scrolloff;
let (view, doc) = current!(cx.editor); 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( fn tree_sitter_scopes(