Skip to content

Commit

Permalink
Scroll on new lines
Browse files Browse the repository at this point in the history
This addition will make sure that the document scrolls properly when inserting a new line. You might want to make it optional and have a setting for it. I am using this by modifying the installed extension code directly, and it works like a charm, but it's not tested properly as I haven't tried compiling the ts files.
  • Loading branch information
Dani Guardiola authored Oct 15, 2020
1 parent d65fb83 commit ca71e7c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/instruction-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ const typeTextIntoActiveTextEditor = async (
editBuilder.insert(editor.selection.active, char!);
if (char === '\n') {
pos = new Position(pos.line + 1, pos.character);
// scroll to last line
const lastLine = editor.document.lineCount - 1;
const lastLineRange = editor.document.lineAt(lastLine).range;
editor.revealRange(lastLineRange);
} else {
pos = new Position(pos.line, pos.character + 1);
}
Expand Down

0 comments on commit ca71e7c

Please sign in to comment.