Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Mar 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 18 additions & 12 deletions src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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]) {
Expand Down