Skip to content

Commit 728b9a0

Browse files
authored
Merge pull request microsoft#189348 from microsoft/tyriar/188076
Remove and fix lines type override in quick fix provider
2 parents 3cc8232 + d39fe95 commit 728b9a0

File tree

1 file changed

+33
-37
lines changed

1 file changed

+33
-37
lines changed

src/vs/workbench/api/browser/mainThreadTerminalService.ts

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ import { withNullAsUndefined } from 'vs/base/common/types';
2121
import { OperatingSystem, OS } from 'vs/base/common/platform';
2222
import { TerminalEditorLocationOptions } from 'vscode';
2323
import { Promises } from 'vs/base/common/async';
24-
import { CancellationToken } from 'vs/base/common/cancellation';
25-
import { ITerminalCommand } from 'vs/platform/terminal/common/capabilities/capabilities';
2624
import { TerminalQuickFixType } from 'vs/workbench/api/common/extHostTypes';
2725
import { ISerializableEnvironmentDescriptionMap, ISerializableEnvironmentVariableCollection } from 'vs/platform/terminal/common/environmentVariable';
2826
import { ITerminalLinkProviderService } from 'vs/workbench/contrib/terminalContrib/links/browser/links';
29-
import { ITerminalQuickFixService, ITerminalQuickFixOptions, ITerminalQuickFix } from 'vs/workbench/contrib/terminalContrib/quickFix/browser/quickFix';
27+
import { ITerminalQuickFixService, ITerminalQuickFix } from 'vs/workbench/contrib/terminalContrib/quickFix/browser/quickFix';
3028

3129

3230
@extHostNamedCustomer(MainContext.MainThreadTerminalService)
@@ -261,42 +259,40 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
261259
}
262260

263261
public async $registerQuickFixProvider(id: string, extensionId: string): Promise<void> {
264-
this._quickFixProviders.set(id, this._terminalQuickFixService.registerQuickFixProvider(id,
265-
{
266-
provideTerminalQuickFixes: async (terminalCommand: ITerminalCommand, lines: string[], option: ITerminalQuickFixOptions, token: CancellationToken) => {
267-
if (token.isCancellationRequested) {
268-
return;
269-
}
270-
if (option.outputMatcher?.length && option.outputMatcher.length > 40) {
271-
option.outputMatcher.length = 40;
272-
this._logService.warn('Cannot exceed output matcher length of 40');
273-
}
274-
const commandLineMatch = terminalCommand.command.match(option.commandLineMatcher);
275-
if (!commandLineMatch) {
276-
return;
277-
}
278-
const outputMatcher = option.outputMatcher;
279-
let outputMatch;
280-
if (outputMatcher) {
281-
outputMatch = getOutputMatchForLines(lines, outputMatcher);
282-
}
283-
if (!outputMatch) {
284-
return;
285-
}
286-
const matchResult = { commandLineMatch, outputMatch, commandLine: terminalCommand.command };
287-
288-
if (matchResult) {
289-
const result = await this._proxy.$provideTerminalQuickFixes(id, matchResult, token);
290-
if (result && Array.isArray(result)) {
291-
return result.map(r => parseQuickFix(id, extensionId, r));
292-
} else if (result) {
293-
return parseQuickFix(id, extensionId, result);
294-
}
295-
}
262+
this._quickFixProviders.set(id, this._terminalQuickFixService.registerQuickFixProvider(id, {
263+
provideTerminalQuickFixes: async (terminalCommand, lines, options, token) => {
264+
if (token.isCancellationRequested) {
265+
return;
266+
}
267+
if (options.outputMatcher?.length && options.outputMatcher.length > 40) {
268+
options.outputMatcher.length = 40;
269+
this._logService.warn('Cannot exceed output matcher length of 40');
270+
}
271+
const commandLineMatch = terminalCommand.command.match(options.commandLineMatcher);
272+
if (!commandLineMatch || !lines) {
273+
return;
274+
}
275+
const outputMatcher = options.outputMatcher;
276+
let outputMatch;
277+
if (outputMatcher) {
278+
outputMatch = getOutputMatchForLines(lines, outputMatcher);
279+
}
280+
if (!outputMatch) {
296281
return;
297282
}
298-
})
299-
);
283+
const matchResult = { commandLineMatch, outputMatch, commandLine: terminalCommand.command };
284+
285+
if (matchResult) {
286+
const result = await this._proxy.$provideTerminalQuickFixes(id, matchResult, token);
287+
if (result && Array.isArray(result)) {
288+
return result.map(r => parseQuickFix(id, extensionId, r));
289+
} else if (result) {
290+
return parseQuickFix(id, extensionId, result);
291+
}
292+
}
293+
return;
294+
}
295+
}));
300296
}
301297

302298
public $unregisterQuickFixProvider(id: string): void {

0 commit comments

Comments
 (0)