Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/instruction-handlers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { commands, Position, Selection, Uri, window, workspace } from 'vscode';
import {
commands,
Position,
Selection,
TextEditorRevealType,
Uri,
window,
workspace,
} from 'vscode';
import { join, dirname } from 'path';

import {
Expand Down Expand Up @@ -66,10 +74,8 @@ 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);
// scroll to current line if needed
editor.revealRange(editor.selection, TextEditorRevealType.Default);
} else {
pos = new Position(pos.line, pos.character + 1);
}
Expand Down Expand Up @@ -124,7 +130,11 @@ export const goto = async (instruction: GoTo): Promise<void> => {

const position = new Position(line - 1, column - 1);
editor.selection = new Selection(position, position);
editor.revealRange(editor.selection);
editor.revealRange(
editor.selection,
TextEditorRevealType.InCenterIfOutsideViewport
);

await timeout(getDelay());
};

Expand Down