Skip to content

Commit

Permalink
Scroll to selection when opening external buffer
Browse files Browse the repository at this point in the history
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 vscode-neovim#993 but for now it makes :help work a lot nicer.
  • Loading branch information
ian-h-chamberlain committed Sep 11, 2023
1 parent 22db9c3 commit 4aae83f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/buffer_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 4aae83f

Please sign in to comment.