From 4aae83fe04a232e555f2f48e067c33c00f5119a9 Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Sun, 10 Sep 2023 22:20:49 -0400 Subject: [PATCH] Scroll to selection when opening external buffer We already set the selection based on the neovim cursor, but we should also scroll so that it's visible. This might be better fixed by something like #993 but for now it makes :help work a lot nicer. --- src/buffer_manager.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/buffer_manager.ts b/src/buffer_manager.ts index 9ae7bcdd8..fb6f05468 100644 --- a/src/buffer_manager.ts +++ b/src/buffer_manager.ts @@ -805,7 +805,10 @@ export class BufferManager implements Disposable, NeovimRedrawProcessable, Neovi } catch (e) { this.logger.warn(`${LOG_PREFIX}: Unable to get cursor pos for external buffer: ${id}`); } - editor.selections = [new Selection(finalLine, finalCol, finalLine, finalCol)]; + + const selection = new Selection(finalLine, finalCol, finalLine, finalCol); + editor.selections = [selection]; + editor.revealRange(selection, TextEditorRevealType.AtTop); } }, 1000);