Skip to content

Commit

Permalink
fix(buffer): scroll to selection on buffer open
Browse files Browse the repository at this point in the history
We already set the selection based on the neovim cursor from the
external buffer, but we should also scroll so that it's visible. This might
be better fixed with proper syncing like vscode-neovim#1261 but for now it makes :help work
a lot nicer.
  • Loading branch information
ian-h-chamberlain committed Sep 11, 2023
1 parent 5b6393c commit 494c857
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 494c857

Please sign in to comment.