Skip to content

Commit

Permalink
Fix bug causing lint processes to sometimes not be killed when desire…
Browse files Browse the repository at this point in the history
…d (#1791)

* Fix bug causing lint processes to sometimes not be killed when desired

* same for goVet
  • Loading branch information
Jackson Kearl authored and ramya-rao-a committed Jul 17, 2018
1 parent da265b0 commit 67d4d93
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/goLint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export function lintCode(lintWorkspace?: boolean) {
* @param lintWorkspace If true runs linter in all workspace.
*/
export function goLint(fileUri: vscode.Uri, goConfig: vscode.WorkspaceConfiguration, lintWorkspace?: boolean): Promise<ICheckResult[]> {
epoch++;
let closureEpoch = epoch;
if (tokenSource) {
if (running) {
tokenSource.cancel();
Expand Down Expand Up @@ -113,12 +115,14 @@ export function goLint(fileUri: vscode.Uri, goConfig: vscode.WorkspaceConfigurat
false,
tokenSource.token
).then((result) => {
running = false;
if (closureEpoch === epoch)
running = false;
return result;
});

return lintPromise;
}

let epoch = 0;
let tokenSource: vscode.CancellationTokenSource;
let running = false;
6 changes: 5 additions & 1 deletion src/goVet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export function vetCode(vetWorkspace?: boolean) {
* @param vetWorkspace If true vets code in all workspace.
*/
export function goVet(fileUri: vscode.Uri, goConfig: vscode.WorkspaceConfiguration, vetWorkspace?: boolean): Promise<ICheckResult[]> {
epoch++;
let closureEpoch = epoch;
if (tokenSource) {
if (running) {
tokenSource.cancel();
Expand Down Expand Up @@ -83,13 +85,15 @@ export function goVet(fileUri: vscode.Uri, goConfig: vscode.WorkspaceConfigurati
false,
tokenSource.token
).then((result) => {
running = false;
if (closureEpoch === epoch)
running = false;
return result;
});
});

return vetPromise;
}

let epoch = 0;
let tokenSource: vscode.CancellationTokenSource;
let running = false;

0 comments on commit 67d4d93

Please sign in to comment.