Skip to content

Commit

Permalink
Cancel 3-state timeout when active document changes
Browse files Browse the repository at this point in the history
Resolves #7
  • Loading branch information
Kai Wood committed Oct 25, 2019
1 parent 42209ea commit 31fd7fa
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export function activate(context: vscode.ExtensionContext) {
}, 1000);
}

vscode.window.onDidChangeActiveTextEditor(() => {
clearTimeout(timeout);
state = "center";
});

let disposable = vscode.commands.registerCommand(
"center-editor-window.center",
() => {
Expand Down Expand Up @@ -49,7 +54,9 @@ export function activate(context: vscode.ExtensionContext) {

async function toCenter() {
let currentLineNumber = vscode.window.activeTextEditor.selection.start.line;
let offset = +vscode.workspace.getConfiguration("center-editor-window").get("offset");
let offset = +vscode.workspace
.getConfiguration("center-editor-window")
.get("offset");
await vscode.commands.executeCommand("revealLine", {
lineNumber: currentLineNumber + offset,
at: "center"
Expand Down

0 comments on commit 31fd7fa

Please sign in to comment.