mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-22 03:09:13 +00:00
terminal.quickFixes -> terminalQuickFixes (#173860)
This commit is contained in:
@@ -40,10 +40,8 @@
|
|||||||
"browser": "./dist/browser/npmBrowserMain",
|
"browser": "./dist/browser/npmBrowserMain",
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
"onTaskType:npm",
|
"onTaskType:npm",
|
||||||
"onCommand:npm.runScriptFromFolder",
|
|
||||||
"onLanguage:json",
|
"onLanguage:json",
|
||||||
"workspaceContains:package.json",
|
"workspaceContains:package.json"
|
||||||
"onView:npm"
|
|
||||||
],
|
],
|
||||||
"capabilities": {
|
"capabilities": {
|
||||||
"virtualWorkspaces": {
|
"virtualWorkspaces": {
|
||||||
@@ -341,8 +339,7 @@
|
|||||||
"when": "shellExecutionSupported"
|
"when": "shellExecutionSupported"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"terminal": {
|
"terminalQuickFixes": [
|
||||||
"quickFixes": [
|
|
||||||
{
|
{
|
||||||
"id": "ms-vscode.npm-command",
|
"id": "ms-vscode.npm-command",
|
||||||
"commandLineMatcher": "npm",
|
"commandLineMatcher": "npm",
|
||||||
@@ -355,7 +352,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import { IPtyHostProcessReplayEvent, ISerializedCommandDetectionCapability, ITer
|
|||||||
import { IGetTerminalLayoutInfoArgs, IProcessDetails, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
|
import { IGetTerminalLayoutInfoArgs, IProcessDetails, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
|
||||||
import { ThemeIcon } from 'vs/base/common/themables';
|
import { ThemeIcon } from 'vs/base/common/themables';
|
||||||
import { ISerializableEnvironmentVariableCollections } from 'vs/platform/terminal/common/environmentVariable';
|
import { ISerializableEnvironmentVariableCollections } from 'vs/platform/terminal/common/environmentVariable';
|
||||||
import { ITerminalCommandSelector } from 'vs/platform/terminal/common/xterm/terminalQuickFix';
|
|
||||||
|
|
||||||
|
|
||||||
export const enum TerminalSettingPrefix {
|
export const enum TerminalSettingPrefix {
|
||||||
Shell = 'terminal.integrated.shell.',
|
Shell = 'terminal.integrated.shell.',
|
||||||
@@ -844,7 +842,6 @@ export interface IShellIntegration {
|
|||||||
|
|
||||||
export interface ITerminalContributions {
|
export interface ITerminalContributions {
|
||||||
profiles?: ITerminalProfileContribution[];
|
profiles?: ITerminalProfileContribution[];
|
||||||
quickFixes?: ITerminalCommandSelector[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum ShellIntegrationStatus {
|
export const enum ShellIntegrationStatus {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export class TerminalQuickFixService implements ITerminalQuickFixService {
|
|||||||
readonly onDidUnregisterProvider = this._onDidUnregisterProvider.event;
|
readonly onDidUnregisterProvider = this._onDidUnregisterProvider.event;
|
||||||
|
|
||||||
constructor(@ITerminalContributionService private readonly _terminalContributionService: ITerminalContributionService) {
|
constructor(@ITerminalContributionService private readonly _terminalContributionService: ITerminalContributionService) {
|
||||||
this._terminalContributionService.quickFixes.then(selectors => {
|
this._terminalContributionService.terminalQuickFixes.then(selectors => {
|
||||||
for (const selector of selectors) {
|
for (const selector of selectors) {
|
||||||
this.registerCommandSelector(selector);
|
this.registerCommandSelector(selector);
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ export class TerminalQuickFixService implements ITerminalQuickFixService {
|
|||||||
// IDisposable synchronously but we must await ITerminalContributionService.quickFixes
|
// IDisposable synchronously but we must await ITerminalContributionService.quickFixes
|
||||||
// asynchronously before actually registering the provider.
|
// asynchronously before actually registering the provider.
|
||||||
let disposed = false;
|
let disposed = false;
|
||||||
this._terminalContributionService.quickFixes.then(() => {
|
this._terminalContributionService.terminalQuickFixes.then(() => {
|
||||||
if (disposed) {
|
if (disposed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export class TerminalQuickFixAddon extends Disposable implements ITerminalAddon,
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
this._register(this._quickFixService.onDidRegisterProvider(result => this.registerCommandFinishedListener(convertToQuickFixOptions(result))));
|
this._register(this._quickFixService.onDidRegisterProvider(result => this.registerCommandFinishedListener(convertToQuickFixOptions(result))));
|
||||||
terminalContributionService.quickFixes.then(quickFixSelectors => {
|
terminalContributionService.terminalQuickFixes.then(quickFixSelectors => {
|
||||||
for (const selector of quickFixSelectors) {
|
for (const selector of quickFixSelectors) {
|
||||||
this.registerCommandSelector(selector);
|
this.registerCommandSelector(selector);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -739,73 +739,12 @@ export const terminalContributionsDescriptor: IExtensionPointDescriptor<ITermina
|
|||||||
for (const profileContrib of (contrib.profiles ?? [])) {
|
for (const profileContrib of (contrib.profiles ?? [])) {
|
||||||
result.push(`onTerminalProfile:${profileContrib.id}`);
|
result.push(`onTerminalProfile:${profileContrib.id}`);
|
||||||
}
|
}
|
||||||
for (const quickFixContrib of (contrib.quickFixes ?? [])) {
|
|
||||||
result.push(`onTerminalQuickFixRequest:${quickFixContrib.id}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
jsonSchema: {
|
jsonSchema: {
|
||||||
description: nls.localize('vscode.extension.contributes.terminal', 'Contributes terminal functionality.'),
|
description: nls.localize('vscode.extension.contributes.terminal', 'Contributes terminal functionality.'),
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
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: {
|
profiles: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
description: nls.localize('vscode.extension.contributes.terminal.profiles', "Defines additional terminal profiles that the user can create."),
|
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 * 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 { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { IExtensionTerminalProfile, ITerminalContributions, ITerminalProfileContribution } from 'vs/platform/terminal/common/terminal';
|
import { IExtensionTerminalProfile, ITerminalContributions, ITerminalProfileContribution } from 'vs/platform/terminal/common/terminal';
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
@@ -13,12 +13,13 @@ import { ITerminalCommandSelector } from 'vs/platform/terminal/common/xterm/term
|
|||||||
|
|
||||||
// terminal extension point
|
// terminal extension point
|
||||||
const terminalsExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<ITerminalContributions>(terminalContributionsDescriptor);
|
const terminalsExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<ITerminalContributions>(terminalContributionsDescriptor);
|
||||||
|
const terminalQuickFixesExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<ITerminalCommandSelector[]>(terminalQuickFixesContributionsDescriptor);
|
||||||
|
|
||||||
export interface ITerminalContributionService {
|
export interface ITerminalContributionService {
|
||||||
readonly _serviceBrand: undefined;
|
readonly _serviceBrand: undefined;
|
||||||
|
|
||||||
readonly terminalProfiles: ReadonlyArray<IExtensionTerminalProfile>;
|
readonly terminalProfiles: ReadonlyArray<IExtensionTerminalProfile>;
|
||||||
readonly quickFixes: Promise<Array<ITerminalCommandSelector>>;
|
readonly terminalQuickFixes: Promise<Array<ITerminalCommandSelector>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ITerminalContributionService = createDecorator<ITerminalContributionService>('terminalContributionsService');
|
export const ITerminalContributionService = createDecorator<ITerminalContributionService>('terminalContributionsService');
|
||||||
@@ -29,18 +30,20 @@ export class TerminalContributionService implements ITerminalContributionService
|
|||||||
private _terminalProfiles: ReadonlyArray<IExtensionTerminalProfile> = [];
|
private _terminalProfiles: ReadonlyArray<IExtensionTerminalProfile> = [];
|
||||||
get terminalProfiles() { return this._terminalProfiles; }
|
get terminalProfiles() { return this._terminalProfiles; }
|
||||||
|
|
||||||
quickFixes: Promise<Array<ITerminalCommandSelector>>;
|
terminalQuickFixes: Promise<Array<ITerminalCommandSelector>>;
|
||||||
|
|
||||||
constructor() {
|
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 => {
|
this._terminalProfiles = contributions.map(c => {
|
||||||
return c.value?.profiles?.filter(p => hasValidTerminalIcon(p)).map(e => {
|
return c.value?.profiles?.filter(p => hasValidTerminalIcon(p)).map(e => {
|
||||||
return { ...e, extensionIdentifier: c.description.identifier.value };
|
return { ...e, extensionIdentifier: c.description.identifier.value };
|
||||||
}) || [];
|
}) || [];
|
||||||
}).flat();
|
}).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
|
rows: 30
|
||||||
});
|
});
|
||||||
instantiationService.stub(IStorageService, new TestStorageService());
|
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(ITerminalQuickFixService, { onDidRegisterProvider: new Emitter().event, onDidUnregisterProvider: new Emitter().event, onDidRegisterCommandSelector: new Emitter().event } as Partial<ITerminalQuickFixService>);
|
||||||
instantiationService.stub(IConfigurationService, new TestConfigurationService());
|
instantiationService.stub(IConfigurationService, new TestConfigurationService());
|
||||||
instantiationService.stub(ILabelService, {} as Partial<ILabelService>);
|
instantiationService.stub(ILabelService, {} as Partial<ILabelService>);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class TestTerminalExtensionService extends TestExtensionService {
|
|||||||
class TestTerminalContributionService implements ITerminalContributionService {
|
class TestTerminalContributionService implements ITerminalContributionService {
|
||||||
_serviceBrand: undefined;
|
_serviceBrand: undefined;
|
||||||
terminalProfiles: readonly IExtensionTerminalProfile[] = [];
|
terminalProfiles: readonly IExtensionTerminalProfile[] = [];
|
||||||
quickFixes: Promise<ITerminalCommandSelector[]> = Promise.resolve([]);
|
terminalQuickFixes: Promise<ITerminalCommandSelector[]> = Promise.resolve([]);
|
||||||
setProfiles(profiles: IExtensionTerminalProfile[]): void {
|
setProfiles(profiles: IExtensionTerminalProfile[]): void {
|
||||||
this.terminalProfiles = profiles;
|
this.terminalProfiles = profiles;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user