Skip to content

Commit

Permalink
Prevent the same problem matcher beginning twice
Browse files Browse the repository at this point in the history
Fixes #44192
  • Loading branch information
Tyriar committed Feb 28, 2018
1 parent fd8e756 commit 9ce68cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/vs/workbench/parts/tasks/common/problemCollectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement
// Current State
private currentOwner: string;
private currentResource: string;
private lastBeginLine: string;

constructor(problemMatchers: ProblemMatcher[], markerService: IMarkerService, modelService: IModelService) {
super(problemMatchers, markerService, modelService);
Expand Down Expand Up @@ -419,11 +420,17 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement
}

private tryBegin(line: string): boolean {
// Disallow multiple consecutive begin lines to be identical in order to catch cases where
// CLI tools will rewrite terminal output, potentially causing tasks to begin multiple times
if (this.lastBeginLine === line) {
return false;
}
let result = false;
for (let i = 0; i < this.watchingBeginsPatterns.length; i++) {
let beginMatcher = this.watchingBeginsPatterns[i];
let matches = beginMatcher.pattern.regexp.exec(line);
if (matches) {
this.lastBeginLine = line;
result = true;
this._onDidStateChange.fire(ProblemCollectorEvent.create(ProblemCollectorEventKind.BackgroundProcessingBegins));
this.cleanMarkerCaches();
Expand All @@ -447,6 +454,7 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement
let endMatcher = this.watchingEndsPatterns[i];
let matches = endMatcher.pattern.regexp.exec(line);
if (matches) {
this.lastBeginLine = null;
this._onDidStateChange.fire(ProblemCollectorEvent.create(ProblemCollectorEventKind.BackgroundProcessingEnds));
result = true;
let owner = endMatcher.problemMatcher.owner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ export class TerminalTaskSystem implements ITaskSystem {
eventCounter++;
this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.Active, task));
} else if (event.kind === ProblemCollectorEventKind.BackgroundProcessingEnds) {
if (eventCounter === 0) {
return;
}
eventCounter--;
this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.Inactive, task));
}
Expand Down

0 comments on commit 9ce68cb

Please sign in to comment.