mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-24 17:31:37 +01:00
make exitStatus mandatory
This commit is contained in:
@@ -19,7 +19,7 @@ export interface ITerminalCommandSelector {
|
||||
extensionId: string;
|
||||
commandLineMatcher: string | RegExp;
|
||||
outputMatcher?: ITerminalOutputMatcher;
|
||||
exitStatus?: boolean;
|
||||
exitStatus: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ export interface ITerminalQuickFixOptions {
|
||||
id: string;
|
||||
commandLineMatcher: string | RegExp;
|
||||
outputMatcher?: ITerminalOutputMatcher;
|
||||
exitStatus?: boolean;
|
||||
exitStatus: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ export interface ITerminalQuickFixOpenerAction {
|
||||
export interface ITerminalCommandSelector {
|
||||
commandLineMatcher: string | RegExp;
|
||||
outputMatcher?: ITerminalOutputMatcher;
|
||||
exitStatus?: boolean;
|
||||
exitStatus: boolean;
|
||||
}
|
||||
|
||||
export type TerminalQuickFixActionInternal = IAction | ITerminalQuickFixCommandAction | ITerminalQuickFixOpenerAction;
|
||||
@@ -59,7 +59,7 @@ export type TerminalQuickFixCallbackExtension = (matchResult: TerminalCommandMat
|
||||
|
||||
|
||||
export interface TerminalCommandMatchResult {
|
||||
command: { command: string; exitStatus?: number };
|
||||
command: { command: string; exitStatus: boolean };
|
||||
commandLineMatch: RegExpMatchArray;
|
||||
// full match and groups
|
||||
|
||||
@@ -87,7 +87,7 @@ export interface ITerminalQuickFixProvider {
|
||||
provideTerminalQuickFixes(commandMatchResult: TerminalCommandMatchResult, token?: CancellationToken): Promise<TerminalQuickFix[] | TerminalQuickFix | undefined>;
|
||||
}
|
||||
export interface ITerminalCommandMatchResult {
|
||||
command: { command: string; exitStatus?: number };
|
||||
command: { command: string; exitStatus: boolean };
|
||||
commandLineMatch: RegExpMatchArray;
|
||||
// full match and groups
|
||||
|
||||
|
||||
@@ -122,7 +122,8 @@ export class TerminalQuickFixAddon extends Disposable implements ITerminalAddon,
|
||||
id: selector.id,
|
||||
type: 'unresolved',
|
||||
commandLineMatcher: selector.commandLineMatcher,
|
||||
outputMatcher: selector.outputMatcher
|
||||
outputMatcher: selector.outputMatcher,
|
||||
exitStatus: selector.exitStatus
|
||||
});
|
||||
this._commandListeners.set(matcherKey, currentOptions);
|
||||
}
|
||||
@@ -261,7 +262,7 @@ export class TerminalQuickFixAddon extends Disposable implements ITerminalAddon,
|
||||
}
|
||||
|
||||
export async function getQuickFixesForCommand(
|
||||
command: ITerminalCommand,
|
||||
terminalCommand: ITerminalCommand,
|
||||
quickFixOptions: Map<string, ITerminalQuickFixOptions[]>,
|
||||
openerService: IOpenerService,
|
||||
onDidRequestRerunCommand?: Emitter<{ command: string; addNewLine?: boolean }>,
|
||||
@@ -270,11 +271,11 @@ export async function getQuickFixesForCommand(
|
||||
const onDidRunQuickFixEmitter = new Emitter<string>();
|
||||
const onDidRunQuickFix = onDidRunQuickFixEmitter.event;
|
||||
const fixes: IAction[] = [];
|
||||
const newCommand = command.command;
|
||||
const newCommand = terminalCommand.command;
|
||||
const expectedCommands = [];
|
||||
for (const options of quickFixOptions.values()) {
|
||||
for (const option of options) {
|
||||
if (option.exitStatus !== undefined && option.exitStatus !== (command.exitCode === 0)) {
|
||||
if (option.exitStatus !== undefined && option.exitStatus !== (terminalCommand.exitCode === 0)) {
|
||||
continue;
|
||||
}
|
||||
const commandLineMatch = newCommand.match(option.commandLineMatcher);
|
||||
@@ -284,22 +285,24 @@ export async function getQuickFixesForCommand(
|
||||
const outputMatcher = option.outputMatcher;
|
||||
let outputMatch;
|
||||
if (outputMatcher) {
|
||||
outputMatch = command.getOutputMatch(outputMatcher);
|
||||
outputMatch = terminalCommand.getOutputMatch(outputMatcher);
|
||||
}
|
||||
const command = { command: newCommand, exitStatus: terminalCommand.exitCode !== 0 };
|
||||
const matchResult = { commandLineMatch, outputMatch, command };
|
||||
const id = option.id;
|
||||
let quickFixes;
|
||||
switch (option.type) {
|
||||
case 'internal':
|
||||
quickFixes = (option as IInternalOptions).getQuickFixes({ commandLineMatch, outputMatch, command });
|
||||
quickFixes = (option as IInternalOptions).getQuickFixes(matchResult);
|
||||
break;
|
||||
case 'resolved':
|
||||
quickFixes = await (option as IResolvedExtensionOptions).getQuickFixes({ commandLineMatch, outputMatch, command }, new CancellationTokenSource().token);
|
||||
quickFixes = await (option as IResolvedExtensionOptions).getQuickFixes(matchResult, new CancellationTokenSource().token);
|
||||
break;
|
||||
case 'unresolved':
|
||||
if (!getResolvedFixes) {
|
||||
throw new Error('No resolved fix provider');
|
||||
}
|
||||
quickFixes = await getResolvedFixes(id, { command, commandLineMatch, outputMatch });
|
||||
quickFixes = await getResolvedFixes(id, matchResult);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -736,7 +736,7 @@ export const terminalContributionsDescriptor: IExtensionPointDescriptor = {
|
||||
description: nls.localize('vscode.extension.contributes.terminal.quickFixes', "Defines quick fixes for terminals with shell integration enabled."),
|
||||
items: {
|
||||
type: 'object',
|
||||
required: ['id', 'commandLineMatcher', 'outputMatcher'],
|
||||
required: ['id', 'commandLineMatcher', 'outputMatcher', 'exitStatus'],
|
||||
defaultSnippets: [{
|
||||
body: {
|
||||
id: '$1',
|
||||
@@ -778,8 +778,8 @@ export const terminalContributionsDescriptor: IExtensionPointDescriptor = {
|
||||
}
|
||||
},
|
||||
exitStatus: {
|
||||
description: nls.localize('vscode.extension.contributes.terminal.quickFixes.exitStatus', "The exit code to expect if any"),
|
||||
type: 'number',
|
||||
description: nls.localize('vscode.extension.contributes.terminal.quickFixes.exitStatus', "True if the exit code is non-zero"),
|
||||
type: 'boolean',
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ export const allApiProposals = Object.freeze({
|
||||
telemetryLogger: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.telemetryLogger.d.ts',
|
||||
terminalDataWriteEvent: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalDataWriteEvent.d.ts',
|
||||
terminalDimensions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalDimensions.d.ts',
|
||||
terminalQuickFixProvider: 'https://raw.githubusercontent.com/microsoft/vscode/merogge/quick-fix-api/src/vscode-dts/vscode.proposed.terminalQuickFixProvider.d.ts',
|
||||
terminalQuickFixProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.terminalQuickFixProvider.d.ts',
|
||||
testCoverage: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testCoverage.d.ts',
|
||||
testObserver: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.testObserver.d.ts',
|
||||
textSearchProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.textSearchProvider.d.ts',
|
||||
|
||||
@@ -18,7 +18,7 @@ declare module 'vscode' {
|
||||
export interface TerminalCommandSelector {
|
||||
commandLineMatcher: string | RegExp;
|
||||
outputMatcher?: TerminalOutputMatcher;
|
||||
exitStatus?: boolean;
|
||||
exitStatus: boolean;
|
||||
}
|
||||
|
||||
export interface TerminalCommandMatchResult {
|
||||
|
||||
Reference in New Issue
Block a user