create problem collector when no problem matchers, but don't process lines (#176818)

This commit is contained in:
Megan Rogge
2023-03-10 17:29:30 -06:00
committed by GitHub
parent 9129e30dad
commit b62c32ef2c
@@ -51,6 +51,7 @@ import { IOutputService } from 'vs/workbench/services/output/common/output';
import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/browser/panecomposite';
import { IPathService } from 'vs/workbench/services/path/common/pathService';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IDisposable } from 'xterm';
interface ITerminalData {
terminal: ITerminalInstance;
@@ -838,8 +839,8 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
let terminal: ITerminalInstance | undefined = undefined;
let error: TaskError | undefined = undefined;
let promise: Promise<ITaskSummary> | undefined = undefined;
const problemMatchers = await this._resolveMatchers(resolver, task.configurationProperties.problemMatchers);
if (task.configurationProperties.isBackground && problemMatchers.length) {
if (task.configurationProperties.isBackground) {
const problemMatchers = await this._resolveMatchers(resolver, task.configurationProperties.problemMatchers);
const watchingProblemMatcher = new WatchingProblemCollector(problemMatchers, this._markerService, this._modelService, this._fileService);
if ((problemMatchers.length > 0) && !watchingProblemMatcher.isWatching()) {
this._appendOutput(nls.localize('TerminalTaskSystem.nonWatchingMatcher', 'Task {0} is a background task but uses a problem matcher without a background pattern', task._label));
@@ -896,20 +897,25 @@ export class TerminalTaskSystem extends Disposable implements ITaskSystem {
this._logService.error('Task terminal process never got ready');
});
this._fireTaskEvent(TaskEvent.create(TaskEventKind.Start, task, terminal.instanceId, resolver.values));
const onData = terminal.onLineData((line) => {
watchingProblemMatcher.processLine(line);
if (!delayer) {
delayer = new Async.Delayer(3000);
}
delayer.trigger(() => {
watchingProblemMatcher.forceDelivery();
delayer = undefined;
let onData: IDisposable | undefined;
if (problemMatchers.length) {
// prevent https://github.com/microsoft/vscode/issues/174511 from happening
onData = terminal.onLineData((line) => {
watchingProblemMatcher.processLine(line);
if (!delayer) {
delayer = new Async.Delayer(3000);
}
delayer.trigger(() => {
watchingProblemMatcher.forceDelivery();
delayer = undefined;
});
});
});
}
promise = new Promise<ITaskSummary>((resolve, reject) => {
const onExit = terminal!.onExit((terminalLaunchResult) => {
const exitCode = typeof terminalLaunchResult === 'number' ? terminalLaunchResult : terminalLaunchResult?.code;
onData.dispose();
onData?.dispose();
onExit.dispose();
const key = task.getMapKey();
if (this._busyTasks[mapKey]) {