Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Run on save actions only for active documents, fixes #2202
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Dec 30, 2018
1 parent 7791044 commit cf0a61c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/goFormat.ts
Expand Up @@ -13,7 +13,11 @@ import { sendTelemetryEvent, getBinPath, getToolsEnvVars, killTree } from './uti

export class GoDocumentFormattingEditProvider implements vscode.DocumentFormattingEditProvider {

public provideDocumentFormattingEdits(document: vscode.TextDocument, options: vscode.FormattingOptions, token: vscode.CancellationToken): Thenable<vscode.TextEdit[]> {
public provideDocumentFormattingEdits(document: vscode.TextDocument, options: vscode.FormattingOptions, token: vscode.CancellationToken): vscode.ProviderResult<vscode.TextEdit[]> {
if (vscode.window.visibleTextEditors.every(e => e.document.fileName !== document.fileName)) {
return [];
}

let filename = document.fileName;
let goConfig = vscode.workspace.getConfiguration('go', document.uri);
let formatTool = goConfig['formatTool'] || 'goreturns';
Expand Down
4 changes: 3 additions & 1 deletion src/goMain.ts
Expand Up @@ -560,7 +560,9 @@ function startBuildOnSaveWatcher(subscriptions: vscode.Disposable[]) {
if (document.languageId !== 'go') {
return;
}
runBuilds(document, vscode.workspace.getConfiguration('go', document.uri));
if (vscode.window.visibleTextEditors.some(e => e.document.fileName === document.fileName)) {
runBuilds(document, vscode.workspace.getConfiguration('go', document.uri));
}
}, null, subscriptions);
}

Expand Down

0 comments on commit cf0a61c

Please sign in to comment.