mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
terminal.quickFixes
-> terminalQuickFixes
(#173860)
This commit is contained in:
parent
a338e70218
commit
2b457a3ae9
|
@ -40,10 +40,8 @@
|
|||
"browser": "./dist/browser/npmBrowserMain",
|
||||
"activationEvents": [
|
||||
"onTaskType:npm",
|
||||
"onCommand:npm.runScriptFromFolder",
|
||||
"onLanguage:json",
|
||||
"workspaceContains:package.json",
|
||||
"onView:npm"
|
||||
"workspaceContains:package.json"
|
||||
],
|
||||
"capabilities": {
|
||||
"virtualWorkspaces": {
|
||||
|
@ -341,8 +339,7 @@
|
|||
"when": "shellExecutionSupported"
|
||||
}
|
||||
],
|
||||
"terminal": {
|
||||
"quickFixes": [
|
||||
"terminalQuickFixes": [
|
||||
{
|
||||
"id": "ms-vscode.npm-command",
|
||||
"commandLineMatcher": "npm",
|
||||
|
@ -355,7 +352,6 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -11,8 +11,6 @@ import { IPtyHostProcessReplayEvent, ISerializedCommandDetectionCapability, ITer
|
|||
import { IGetTerminalLayoutInfoArgs, IProcessDetails, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
|
||||
import { ThemeIcon } from 'vs/base/common/themables';
|
||||
import { ISerializableEnvironmentVariableCollections } from 'vs/platform/terminal/common/environmentVariable';
|
||||
import { ITerminalCommandSelector } from 'vs/platform/terminal/common/xterm/terminalQuickFix';
|
||||
|
||||
|
||||
export const enum TerminalSettingPrefix {
|
||||
Shell = 'terminal.integrated.shell.',
|
||||
|
@ -844,7 +842,6 @@ export interface IShellIntegration {
|
|||
|
||||
export interface ITerminalContributions {
|
||||
profiles?: ITerminalProfileContribution[];
|
||||
quickFixes?: ITerminalCommandSelector[];
|
||||
}
|
||||
|
||||
export const enum ShellIntegrationStatus {
|
||||
|
|
|
@ -25,7 +25,7 @@ export class TerminalQuickFixService implements ITerminalQuickFixService {
|
|||
readonly onDidUnregisterProvider = this._onDidUnregisterProvider.event;
|
||||
|
||||
constructor(@ITerminalContributionService private readonly _terminalContributionService: ITerminalContributionService) {
|
||||
this._terminalContributionService.quickFixes.then(selectors => {
|
||||
this._terminalContributionService.terminalQuickFixes.then(selectors => {
|
||||
for (const selector of selectors) {
|
||||
this.registerCommandSelector(selector);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ export class TerminalQuickFixService implements ITerminalQuickFixService {
|
|||
// IDisposable synchronously but we must await ITerminalContributionService.quickFixes
|
||||
// asynchronously before actually registering the provider.
|
||||
let disposed = false;
|
||||
this._terminalContributionService.quickFixes.then(() => {
|
||||
this._terminalContributionService.terminalQuickFixes.then(() => {
|
||||
if (disposed) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ export class TerminalQuickFixAddon extends Disposable implements ITerminalAddon,
|
|||
}));
|
||||
}
|
||||
this._register(this._quickFixService.onDidRegisterProvider(result => this.registerCommandFinishedListener(convertToQuickFixOptions(result))));
|
||||
terminalContributionService.quickFixes.then(quickFixSelectors => {
|
||||
terminalContributionService.terminalQuickFixes.then(quickFixSelectors => {
|
||||
for (const selector of quickFixSelectors) {
|
||||
this.registerCommandSelector(selector);
|
||||
}
|
||||
|
|
|
@ -739,73 +739,12 @@ export const terminalContributionsDescriptor: IExtensionPointDescriptor<ITermina
|
|||
for (const profileContrib of (contrib.profiles ?? [])) {
|
||||
result.push(`onTerminalProfile:${profileContrib.id}`);
|
||||
}
|
||||
for (const quickFixContrib of (contrib.quickFixes ?? [])) {
|
||||
result.push(`onTerminalQuickFixRequest:${quickFixContrib.id}`);
|
||||
}
|
||||
}
|
||||
},
|
||||
jsonSchema: {
|
||||
description: nls.localize('vscode.extension.contributes.terminal', 'Contributes terminal functionality.'),
|
||||
type: 'object',
|
||||
properties: {
|
||||
quickFixes: {
|
||||
type: 'array',
|
||||
description: nls.localize('vscode.extension.contributes.terminal.quickFixes', "Defines quick fixes for terminals with shell integration enabled."),
|
||||
items: {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['id', 'commandLineMatcher', 'outputMatcher', 'commandExitResult'],
|
||||
defaultSnippets: [{
|
||||
body: {
|
||||
id: '$1',
|
||||
commandLineMatcher: '$2',
|
||||
outputMatcher: '$3',
|
||||
exitStatus: '$4'
|
||||
}
|
||||
}],
|
||||
properties: {
|
||||
id: {
|
||||
description: nls.localize('vscode.extension.contributes.terminal.quickFixes.id', "The ID of the quick fix provider"),
|
||||
type: 'string',
|
||||
},
|
||||
commandLineMatcher: {
|
||||
description: nls.localize('vscode.extension.contributes.terminal.quickFixes.commandLineMatcher', "A regular expression or string to test the command line against"),
|
||||
type: 'string',
|
||||
},
|
||||
outputMatcher: {
|
||||
markdownDescription: nls.localize('vscode.extension.contributes.terminal.quickFixes.outputMatcher', "A regular expression or string to test the output against, which provides groups to be referenced in terminalCommand and uri.\n\nFor example:\n\n `lineMatcher: /git push --set-upstream origin (?<branchName>[^\s]+)/;`\n\n`terminalCommand: 'git push --set-upstream origin ${group:branchName}';`\n"),
|
||||
type: 'object',
|
||||
required: ['lineMatcher', 'anchor', 'offset', 'length'],
|
||||
properties: {
|
||||
lineMatcher: {
|
||||
description: 'A regular expression or string to test the command line against',
|
||||
type: 'string'
|
||||
},
|
||||
anchor: {
|
||||
description: 'Where the search should begin in the buffer',
|
||||
enum: ['top', 'bottom']
|
||||
},
|
||||
offset: {
|
||||
description: 'The number of lines vertically from the anchor in the buffer to start matching against',
|
||||
type: 'number'
|
||||
},
|
||||
length: {
|
||||
description: 'The number of rows to match against, this should be as small as possible for performance reasons',
|
||||
type: 'number'
|
||||
}
|
||||
}
|
||||
},
|
||||
commandExitResult: {
|
||||
description: nls.localize('vscode.extension.contributes.terminal.quickFixes.commandExitResult', "The command exit result to match on"),
|
||||
enum: ['success', 'error'],
|
||||
enumDescriptions: [
|
||||
'The command exited with an exit code of zero.',
|
||||
'The command exited with a non-zero exit code.'
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
profiles: {
|
||||
type: 'array',
|
||||
description: nls.localize('vscode.extension.contributes.terminal.profiles', "Defines additional terminal profiles that the user can create."),
|
||||
|
@ -852,3 +791,71 @@ export const terminalContributionsDescriptor: IExtensionPointDescriptor<ITermina
|
|||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const terminalQuickFixesContributionsDescriptor: IExtensionPointDescriptor<ITerminalCommandSelector[]> = {
|
||||
extensionPoint: 'terminalQuickFixes',
|
||||
defaultExtensionKind: ['workspace'],
|
||||
activationEventsGenerator: (terminalQuickFixes: ITerminalCommandSelector[], result: { push(item: string): void }) => {
|
||||
for (const quickFixContrib of terminalQuickFixes ?? []) {
|
||||
result.push(`onTerminalQuickFixRequest:${quickFixContrib.id}`);
|
||||
}
|
||||
},
|
||||
jsonSchema: {
|
||||
description: nls.localize('vscode.extension.contributes.terminalQuickFixes', 'Contributes terminal quick fixes.'),
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
additionalProperties: false,
|
||||
required: ['id', 'commandLineMatcher', 'outputMatcher', 'commandExitResult'],
|
||||
defaultSnippets: [{
|
||||
body: {
|
||||
id: '$1',
|
||||
commandLineMatcher: '$2',
|
||||
outputMatcher: '$3',
|
||||
exitStatus: '$4'
|
||||
}
|
||||
}],
|
||||
properties: {
|
||||
id: {
|
||||
description: nls.localize('vscode.extension.contributes.terminalQuickFixes.id', "The ID of the quick fix provider"),
|
||||
type: 'string',
|
||||
},
|
||||
commandLineMatcher: {
|
||||
description: nls.localize('vscode.extension.contributes.terminalQuickFixes.commandLineMatcher', "A regular expression or string to test the command line against"),
|
||||
type: 'string',
|
||||
},
|
||||
outputMatcher: {
|
||||
markdownDescription: nls.localize('vscode.extension.contributes.terminalQuickFixes.outputMatcher', "A regular expression or string to test the output against, which provides groups to be referenced in terminalCommand and uri.\n\nFor example:\n\n `lineMatcher: /git push --set-upstream origin (?<branchName>[^\s]+)/;`\n\n`terminalCommand: 'git push --set-upstream origin ${group:branchName}';`\n"),
|
||||
type: 'object',
|
||||
required: ['lineMatcher', 'anchor', 'offset', 'length'],
|
||||
properties: {
|
||||
lineMatcher: {
|
||||
description: 'A regular expression or string to test the command line against',
|
||||
type: 'string'
|
||||
},
|
||||
anchor: {
|
||||
description: 'Where the search should begin in the buffer',
|
||||
enum: ['top', 'bottom']
|
||||
},
|
||||
offset: {
|
||||
description: 'The number of lines vertically from the anchor in the buffer to start matching against',
|
||||
type: 'number'
|
||||
},
|
||||
length: {
|
||||
description: 'The number of rows to match against, this should be as small as possible for performance reasons',
|
||||
type: 'number'
|
||||
}
|
||||
}
|
||||
},
|
||||
commandExitResult: {
|
||||
description: nls.localize('vscode.extension.contributes.terminalQuickFixes.commandExitResult', "The command exit result to match on"),
|
||||
enum: ['success', 'error'],
|
||||
enumDescriptions: [
|
||||
'The command exited with an exit code of zero.',
|
||||
'The command exited with a non-zero exit code.'
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as extensionsRegistry from 'vs/workbench/services/extensions/common/extensionsRegistry';
|
||||
import { terminalContributionsDescriptor } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { terminalContributionsDescriptor, terminalQuickFixesContributionsDescriptor } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IExtensionTerminalProfile, ITerminalContributions, ITerminalProfileContribution } from 'vs/platform/terminal/common/terminal';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
@ -13,12 +13,13 @@ import { ITerminalCommandSelector } from 'vs/platform/terminal/common/xterm/term
|
|||
|
||||
// terminal extension point
|
||||
const terminalsExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<ITerminalContributions>(terminalContributionsDescriptor);
|
||||
const terminalQuickFixesExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<ITerminalCommandSelector[]>(terminalQuickFixesContributionsDescriptor);
|
||||
|
||||
export interface ITerminalContributionService {
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
readonly terminalProfiles: ReadonlyArray<IExtensionTerminalProfile>;
|
||||
readonly quickFixes: Promise<Array<ITerminalCommandSelector>>;
|
||||
readonly terminalQuickFixes: Promise<Array<ITerminalCommandSelector>>;
|
||||
}
|
||||
|
||||
export const ITerminalContributionService = createDecorator<ITerminalContributionService>('terminalContributionsService');
|
||||
|
@ -29,18 +30,20 @@ export class TerminalContributionService implements ITerminalContributionService
|
|||
private _terminalProfiles: ReadonlyArray<IExtensionTerminalProfile> = [];
|
||||
get terminalProfiles() { return this._terminalProfiles; }
|
||||
|
||||
quickFixes: Promise<Array<ITerminalCommandSelector>>;
|
||||
terminalQuickFixes: Promise<Array<ITerminalCommandSelector>>;
|
||||
|
||||
constructor() {
|
||||
this.quickFixes = new Promise((r) => terminalsExtPoint.setHandler(contributions => {
|
||||
this.terminalQuickFixes = new Promise((r) => terminalQuickFixesExtPoint.setHandler(fixes => {
|
||||
const quickFixes = (fixes.filter(c => isProposedApiEnabled(c.description, 'terminalQuickFixProvider')).map(c => c.value ? c.value.map(fix => { return { ...fix, extensionIdentifier: c.description.identifier.value }; }) : [])).flat();
|
||||
r(quickFixes);
|
||||
}));
|
||||
terminalsExtPoint.setHandler(contributions => {
|
||||
this._terminalProfiles = contributions.map(c => {
|
||||
return c.value?.profiles?.filter(p => hasValidTerminalIcon(p)).map(e => {
|
||||
return { ...e, extensionIdentifier: c.description.identifier.value };
|
||||
}) || [];
|
||||
}).flat();
|
||||
const quickFixes = (contributions.filter(c => isProposedApiEnabled(c.description, 'terminalQuickFixProvider')).map(c => c.value.quickFixes ? c.value.quickFixes.map(fix => { return { ...fix, extensionIdentifier: c.description.identifier.value }; }) : [])).flat();
|
||||
r(quickFixes);
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ suite('QuickFixAddon', () => {
|
|||
rows: 30
|
||||
});
|
||||
instantiationService.stub(IStorageService, new TestStorageService());
|
||||
instantiationService.stub(ITerminalContributionService, { quickFixes: Promise.resolve([]) } as Partial<ITerminalContributionService>);
|
||||
instantiationService.stub(ITerminalContributionService, { terminalQuickFixes: Promise.resolve([]) } as Partial<ITerminalContributionService>);
|
||||
instantiationService.stub(ITerminalQuickFixService, { onDidRegisterProvider: new Emitter().event, onDidUnregisterProvider: new Emitter().event, onDidRegisterCommandSelector: new Emitter().event } as Partial<ITerminalQuickFixService>);
|
||||
instantiationService.stub(IConfigurationService, new TestConfigurationService());
|
||||
instantiationService.stub(ILabelService, {} as Partial<ILabelService>);
|
||||
|
|
|
@ -90,7 +90,7 @@ class TestTerminalExtensionService extends TestExtensionService {
|
|||
class TestTerminalContributionService implements ITerminalContributionService {
|
||||
_serviceBrand: undefined;
|
||||
terminalProfiles: readonly IExtensionTerminalProfile[] = [];
|
||||
quickFixes: Promise<ITerminalCommandSelector[]> = Promise.resolve([]);
|
||||
terminalQuickFixes: Promise<ITerminalCommandSelector[]> = Promise.resolve([]);
|
||||
setProfiles(profiles: IExtensionTerminalProfile[]): void {
|
||||
this.terminalProfiles = profiles;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue