提交 1d237013 编写于 作者: D Dirk Baeumer

Fixes #46439: Task exit code is set to 1 regardless of problem severity

上级 a7e2e2d7
......@@ -12,7 +12,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import { IModelService } from 'vs/editor/common/services/modelService';
import { ILineMatcher, createLineMatcher, ProblemMatcher, ProblemMatch, ApplyToKind, WatchingPattern, getResource } from 'vs/workbench/parts/tasks/common/problemMatcher';
import { IMarkerService, IMarkerData } from 'vs/platform/markers/common/markers';
import { IMarkerService, IMarkerData, MarkerSeverity } from 'vs/platform/markers/common/markers';
import { generateUuid } from 'vs/base/common/uuid';
export enum ProblemCollectorEventKind {
......@@ -39,6 +39,7 @@ export class AbstractProblemCollector implements IDisposable {
private matchers: INumberDictionary<ILineMatcher[]>;
private activeMatcher: ILineMatcher;
private _numberOfMatches: number;
private _maxMarkerSeverity: MarkerSeverity;
private buffer: string[];
private bufferLength: number;
private openModels: IStringDictionary<boolean>;
......@@ -73,6 +74,7 @@ export class AbstractProblemCollector implements IDisposable {
this.buffer = [];
this.activeMatcher = null;
this._numberOfMatches = 0;
this._maxMarkerSeverity = undefined;
this.openModels = Object.create(null);
this.modelListeners = [];
this.applyToByOwner = new Map<string, ApplyToKind>();
......@@ -110,12 +112,16 @@ export class AbstractProblemCollector implements IDisposable {
return this._numberOfMatches;
}
public get maxMarkerSeverity(): MarkerSeverity {
return this._maxMarkerSeverity;
}
protected tryFindMarker(line: string): ProblemMatch {
let result: ProblemMatch = null;
if (this.activeMatcher) {
result = this.activeMatcher.next(line);
if (result) {
this._numberOfMatches++;
this.captureMatch(result);
return result;
}
this.clearBuffer();
......@@ -170,7 +176,7 @@ export class AbstractProblemCollector implements IDisposable {
let matcher = candidates[i];
let result = matcher.handle(this.buffer, startIndex);
if (result.match) {
this._numberOfMatches++;
this.captureMatch(result.match);
if (result.continue) {
this.activeMatcher = matcher;
}
......@@ -181,6 +187,13 @@ export class AbstractProblemCollector implements IDisposable {
return null;
}
private captureMatch(match: ProblemMatch): void {
this._numberOfMatches++;
if (this._maxMarkerSeverity === void 0 || match.marker.severity > this._maxMarkerSeverity) {
this._maxMarkerSeverity = match.marker.severity;
}
}
private clearBuffer(): void {
if (this.buffer.length > 0) {
this.buffer = [];
......@@ -300,6 +313,8 @@ export class AbstractProblemCollector implements IDisposable {
}
protected cleanMarkerCaches(): void {
this._numberOfMatches = 0;
this._maxMarkerSeverity = undefined;
this.markers.clear();
this.deliveredMarkers.clear();
}
......@@ -464,10 +479,10 @@ export class WatchingProblemCollector extends AbstractProblemCollector implement
if (matches) {
if (this._activeBackgroundMatchers.has(background.key)) {
this._activeBackgroundMatchers.delete(background.key);
this.resetCurrentResource();
this._onDidStateChange.fire(ProblemCollectorEvent.create(ProblemCollectorEventKind.BackgroundProcessingEnds));
result = true;
let owner = background.matcher.owner;
this.resetCurrentResource();
this.cleanMarkers(owner);
this.cleanMarkerCaches();
}
......
......@@ -20,7 +20,7 @@ import { Event, Emitter } from 'vs/base/common/event';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import * as TPath from 'vs/base/common/paths';
import { IMarkerService } from 'vs/platform/markers/common/markers';
import { IMarkerService, MarkerSeverity } from 'vs/platform/markers/common/markers';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IModelService } from 'vs/editor/common/services/modelService';
import { ProblemMatcher, ProblemMatcherRegistry /*, ProblemPattern, getResource */ } from 'vs/workbench/parts/tasks/common/problemMatcher';
......@@ -290,6 +290,13 @@ export class TerminalTaskSystem implements ITaskSystem {
} else if (event.kind === ProblemCollectorEventKind.BackgroundProcessingEnds) {
eventCounter--;
this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.Inactive, task));
if (eventCounter === 0) {
let reveal = task.command.presentation.reveal;
if (reveal === RevealKind.Silent && watchingProblemMatcher.numberOfMatches > 0 && watchingProblemMatcher.maxMarkerSeverity >= MarkerSeverity.Error) {
this.terminalService.setActiveInstance(terminal);
this.terminalService.showPanel(false);
}
}
}
}));
watchingProblemMatcher.aboutToStart();
......@@ -324,6 +331,11 @@ export class TerminalTaskSystem implements ITaskSystem {
this.idleTaskTerminals.set(key, terminal.id.toString(), Touch.AsOld);
break;
}
let reveal = task.command.presentation.reveal;
if (reveal === RevealKind.Silent && (exitCode !== 0 || watchingProblemMatcher.numberOfMatches > 0 && watchingProblemMatcher.maxMarkerSeverity >= MarkerSeverity.Error)) {
this.terminalService.setActiveInstance(terminal);
this.terminalService.showPanel(false);
}
watchingProblemMatcher.done();
watchingProblemMatcher.dispose();
registeredLinkMatchers.forEach(handle => terminal.deregisterLinkMatcher(handle));
......@@ -334,11 +346,6 @@ export class TerminalTaskSystem implements ITaskSystem {
this._onDidStateChange.fire(event);
}
eventCounter = 0;
let reveal = task.command.presentation.reveal;
if (exitCode && exitCode === 1 && watchingProblemMatcher.numberOfMatches === 0 && reveal !== RevealKind.Never) {
this.terminalService.setActiveInstance(terminal);
this.terminalService.showPanel(false);
}
this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.End, task));
resolve({ exitCode });
});
......@@ -371,15 +378,16 @@ export class TerminalTaskSystem implements ITaskSystem {
this.idleTaskTerminals.set(key, terminal.id.toString(), Touch.AsOld);
break;
}
let reveal = task.command.presentation.reveal;
if (reveal === RevealKind.Silent && (exitCode !== 0 || startStopProblemMatcher.numberOfMatches > 0 && startStopProblemMatcher.maxMarkerSeverity >= MarkerSeverity.Error)) {
this.terminalService.setActiveInstance(terminal);
this.terminalService.showPanel(false);
}
startStopProblemMatcher.done();
startStopProblemMatcher.dispose();
registeredLinkMatchers.forEach(handle => terminal.deregisterLinkMatcher(handle));
this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.Inactive, task));
this._onDidStateChange.fire(TaskEvent.create(TaskEventKind.End, task));
// See https://github.com/Microsoft/vscode/issues/31965
if (exitCode === 0 && startStopProblemMatcher.numberOfMatches > 0) {
exitCode = 1;
}
resolve({ exitCode });
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册