mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
parent
2159f75d4b
commit
5edcca3b38
|
@ -78,7 +78,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
const lines = outputMatch.regexMatch[1];
|
const lines = outputMatch.regexMatch[1];
|
||||||
const fixes: vscode.TerminalQuickFixCommand[] = [];
|
const fixes: vscode.TerminalQuickFixExecuteTerminalCommand[] = [];
|
||||||
for (const line of lines.split('\n')) {
|
for (const line of lines.split('\n')) {
|
||||||
// search from the second char, since the lines might be prefixed with
|
// search from the second char, since the lines might be prefixed with
|
||||||
// "npm ERR!" which comes before the actual command suggestion.
|
// "npm ERR!" which comes before the actual command suggestion.
|
||||||
|
|
|
@ -1452,7 +1452,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||||
TaskRevealKind: extHostTypes.TaskRevealKind,
|
TaskRevealKind: extHostTypes.TaskRevealKind,
|
||||||
TaskScope: extHostTypes.TaskScope,
|
TaskScope: extHostTypes.TaskScope,
|
||||||
TerminalLink: extHostTypes.TerminalLink,
|
TerminalLink: extHostTypes.TerminalLink,
|
||||||
TerminalQuickFixCommand: extHostTypes.TerminalQuickFixCommand,
|
TerminalQuickFixExecuteTerminalCommand: extHostTypes.TerminalQuickFixCommand,
|
||||||
TerminalQuickFixOpener: extHostTypes.TerminalQuickFixOpener,
|
TerminalQuickFixOpener: extHostTypes.TerminalQuickFixOpener,
|
||||||
TerminalLocation: extHostTypes.TerminalLocation,
|
TerminalLocation: extHostTypes.TerminalLocation,
|
||||||
TerminalProfile: extHostTypes.TerminalProfile,
|
TerminalProfile: extHostTypes.TerminalProfile,
|
||||||
|
|
|
@ -73,10 +73,8 @@ import { CandidatePort } from 'vs/workbench/services/remote/common/remoteExplore
|
||||||
import { ITextQueryBuilderOptions } from 'vs/workbench/services/search/common/queryBuilder';
|
import { ITextQueryBuilderOptions } from 'vs/workbench/services/search/common/queryBuilder';
|
||||||
import * as search from 'vs/workbench/services/search/common/search';
|
import * as search from 'vs/workbench/services/search/common/search';
|
||||||
import { ISaveProfileResult } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
|
import { ISaveProfileResult } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
|
||||||
import { TerminalCommandMatchResult, TerminalQuickFixCommand, TerminalQuickFixOpener } from 'vscode';
|
// TODO: These shouldn't be pulled from the API
|
||||||
|
import { TerminalCommandMatchResult } from 'vscode';
|
||||||
export type TerminalQuickFix = TerminalQuickFixCommand | TerminalQuickFixOpener;
|
|
||||||
|
|
||||||
|
|
||||||
export interface IWorkspaceData extends IStaticWorkspaceData {
|
export interface IWorkspaceData extends IStaticWorkspaceData {
|
||||||
folders: { uri: UriComponents; name: string; index: number }[];
|
folders: { uri: UriComponents; name: string; index: number }[];
|
||||||
|
@ -2010,6 +2008,18 @@ export interface ITerminalDimensionsDto {
|
||||||
rows: number;
|
rows: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SingleOrMany<T> = T[] | T;
|
||||||
|
|
||||||
|
export interface ITerminalQuickFixExecuteTerminalCommandDto {
|
||||||
|
terminalCommand: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ITerminalQuickFixOpenerDto {
|
||||||
|
uri: UriComponents;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TerminalQuickFix = ITerminalQuickFixExecuteTerminalCommandDto | ITerminalQuickFixOpenerDto | ICommandDto;
|
||||||
|
|
||||||
export interface ExtHostTerminalServiceShape {
|
export interface ExtHostTerminalServiceShape {
|
||||||
$acceptTerminalClosed(id: number, exitCode: number | undefined, exitReason: TerminalExitReason): void;
|
$acceptTerminalClosed(id: number, exitCode: number | undefined, exitReason: TerminalExitReason): void;
|
||||||
$acceptTerminalOpened(id: number, extHostTerminalId: string | undefined, name: string, shellLaunchConfig: IShellLaunchConfigDto): void;
|
$acceptTerminalOpened(id: number, extHostTerminalId: string | undefined, name: string, shellLaunchConfig: IShellLaunchConfigDto): void;
|
||||||
|
@ -2034,7 +2044,7 @@ export interface ExtHostTerminalServiceShape {
|
||||||
$initEnvironmentVariableCollections(collections: [string, ISerializableEnvironmentVariableCollection][]): void;
|
$initEnvironmentVariableCollections(collections: [string, ISerializableEnvironmentVariableCollection][]): void;
|
||||||
$acceptDefaultProfile(profile: ITerminalProfile, automationProfile: ITerminalProfile): void;
|
$acceptDefaultProfile(profile: ITerminalProfile, automationProfile: ITerminalProfile): void;
|
||||||
$createContributedProfileTerminal(id: string, options: ICreateContributedTerminalProfileOptions): Promise<void>;
|
$createContributedProfileTerminal(id: string, options: ICreateContributedTerminalProfileOptions): Promise<void>;
|
||||||
$provideTerminalQuickFixes(id: string, matchResult: TerminalCommandMatchResult, token: CancellationToken): Promise<TerminalQuickFix[] | TerminalQuickFix | undefined>;
|
$provideTerminalQuickFixes(id: string, matchResult: TerminalCommandMatchResult, token: CancellationToken): Promise<SingleOrMany<TerminalQuickFix> | undefined>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ExtHostSCMShape {
|
export interface ExtHostSCMShape {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
import type * as vscode from 'vscode';
|
import type * as vscode from 'vscode';
|
||||||
import { Event, Emitter } from 'vs/base/common/event';
|
import { Event, Emitter } from 'vs/base/common/event';
|
||||||
import { ExtHostTerminalServiceShape, MainContext, MainThreadTerminalServiceShape, ITerminalDimensionsDto, ITerminalLinkDto, ExtHostTerminalIdentifier } from 'vs/workbench/api/common/extHost.protocol';
|
import { ExtHostTerminalServiceShape, MainContext, MainThreadTerminalServiceShape, ITerminalDimensionsDto, ITerminalLinkDto, ExtHostTerminalIdentifier, ICommandDto, ITerminalQuickFixOpenerDto, ITerminalQuickFixExecuteTerminalCommandDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||||
|
@ -24,8 +24,9 @@ import { ThemeColor } from 'vs/base/common/themables';
|
||||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||||
import { Promises } from 'vs/base/common/async';
|
import { Promises } from 'vs/base/common/async';
|
||||||
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||||
import { ViewColumn } from 'vs/workbench/api/common/extHostTypeConverters';
|
import { TerminalQuickFix, ViewColumn } from 'vs/workbench/api/common/extHostTypeConverters';
|
||||||
import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
|
import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
|
||||||
|
import { IExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||||
|
|
||||||
export interface IExtHostTerminalService extends ExtHostTerminalServiceShape, IDisposable {
|
export interface IExtHostTerminalService extends ExtHostTerminalServiceShape, IDisposable {
|
||||||
|
|
||||||
|
@ -395,6 +396,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
supportsProcesses: boolean,
|
supportsProcesses: boolean,
|
||||||
|
@IExtHostCommands private readonly _extHostCommands: IExtHostCommands,
|
||||||
@IExtHostRpcService extHostRpc: IExtHostRpcService
|
@IExtHostRpcService extHostRpc: IExtHostRpcService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
@ -692,7 +694,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async $provideTerminalQuickFixes(id: string, matchResult: vscode.TerminalCommandMatchResult): Promise<(vscode.TerminalQuickFixOpener | vscode.TerminalQuickFixCommand)[] | vscode.TerminalQuickFixOpener | vscode.TerminalQuickFixCommand | undefined> {
|
public async $provideTerminalQuickFixes(id: string, matchResult: vscode.TerminalCommandMatchResult): Promise<(ITerminalQuickFixExecuteTerminalCommandDto | ITerminalQuickFixOpenerDto | ICommandDto)[] | ITerminalQuickFixExecuteTerminalCommandDto | ITerminalQuickFixOpenerDto | ICommandDto | undefined> {
|
||||||
const token = new CancellationTokenSource().token;
|
const token = new CancellationTokenSource().token;
|
||||||
if (token.isCancellationRequested) {
|
if (token.isCancellationRequested) {
|
||||||
return;
|
return;
|
||||||
|
@ -702,11 +704,26 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const quickFixes = await provider.provideTerminalQuickFixes(matchResult, token);
|
const quickFixes = await provider.provideTerminalQuickFixes(matchResult, token);
|
||||||
if (quickFixes === null) {
|
if (quickFixes === null || (Array.isArray(quickFixes) && quickFixes.length === 0)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
} else {
|
|
||||||
return quickFixes;
|
|
||||||
}
|
}
|
||||||
|
// Single
|
||||||
|
|
||||||
|
// TODO: Handle this properly
|
||||||
|
const store = new DisposableStore();
|
||||||
|
|
||||||
|
if (!Array.isArray(quickFixes)) {
|
||||||
|
return quickFixes ? TerminalQuickFix.from(quickFixes, this._extHostCommands.converter, store) : undefined;
|
||||||
|
}
|
||||||
|
// Many
|
||||||
|
const result = [];
|
||||||
|
for (const fix of quickFixes) {
|
||||||
|
const converted = TerminalQuickFix.from(fix, this._extHostCommands.converter, store);
|
||||||
|
if (converted) {
|
||||||
|
result.push(converted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async $createContributedProfileTerminal(id: string, options: ICreateContributedTerminalProfileOptions): Promise<void> {
|
public async $createContributedProfileTerminal(id: string, options: ICreateContributedTerminalProfileOptions): Promise<void> {
|
||||||
|
@ -1112,9 +1129,10 @@ class ScopedEnvironmentVariableCollection implements vscode.EnvironmentVariableC
|
||||||
|
|
||||||
export class WorkerExtHostTerminalService extends BaseExtHostTerminalService {
|
export class WorkerExtHostTerminalService extends BaseExtHostTerminalService {
|
||||||
constructor(
|
constructor(
|
||||||
|
@IExtHostCommands extHostCommands: IExtHostCommands,
|
||||||
@IExtHostRpcService extHostRpc: IExtHostRpcService
|
@IExtHostRpcService extHostRpc: IExtHostRpcService
|
||||||
) {
|
) {
|
||||||
super(false, extHostRpc);
|
super(false, extHostCommands, extHostRpc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createTerminal(name?: string, shellPath?: string, shellArgs?: string[] | string): vscode.Terminal {
|
public createTerminal(name?: string, shellPath?: string, shellArgs?: string[] | string): vscode.Terminal {
|
||||||
|
|
|
@ -2155,3 +2155,15 @@ export namespace ChatFollowup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export namespace TerminalQuickFix {
|
||||||
|
export function from(quickFix: vscode.TerminalQuickFixExecuteTerminalCommand | vscode.TerminalQuickFixOpener | vscode.Command, converter: Command.ICommandsConverter, disposables: DisposableStore): extHostProtocol.ITerminalQuickFixExecuteTerminalCommandDto | extHostProtocol.ITerminalQuickFixOpenerDto | extHostProtocol.ICommandDto | undefined {
|
||||||
|
if ('terminalCommand' in quickFix) {
|
||||||
|
return { terminalCommand: quickFix.terminalCommand };
|
||||||
|
}
|
||||||
|
if ('uri' in quickFix) {
|
||||||
|
return { uri: quickFix.uri };
|
||||||
|
}
|
||||||
|
return converter.toInternal(quickFix, disposables);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -7,13 +7,15 @@ import { generateUuid } from 'vs/base/common/uuid';
|
||||||
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
||||||
import { BaseExtHostTerminalService, ExtHostTerminal, ITerminalInternalOptions } from 'vs/workbench/api/common/extHostTerminalService';
|
import { BaseExtHostTerminalService, ExtHostTerminal, ITerminalInternalOptions } from 'vs/workbench/api/common/extHostTerminalService';
|
||||||
import type * as vscode from 'vscode';
|
import type * as vscode from 'vscode';
|
||||||
|
import { IExtHostCommands } from 'vs/workbench/api/common/extHostCommands';
|
||||||
|
|
||||||
export class ExtHostTerminalService extends BaseExtHostTerminalService {
|
export class ExtHostTerminalService extends BaseExtHostTerminalService {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@IExtHostCommands extHostCommands: IExtHostCommands,
|
||||||
@IExtHostRpcService extHostRpc: IExtHostRpcService
|
@IExtHostRpcService extHostRpc: IExtHostRpcService
|
||||||
) {
|
) {
|
||||||
super(true, extHostRpc);
|
super(true, extHostCommands, extHostRpc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public createTerminal(name?: string, shellPath?: string, shellArgs?: string[] | string): vscode.Terminal {
|
public createTerminal(name?: string, shellPath?: string, shellArgs?: string[] | string): vscode.Terminal {
|
||||||
|
|
|
@ -7,6 +7,8 @@ declare module 'vscode' {
|
||||||
|
|
||||||
// https://github.com/microsoft/vscode/issues/162950
|
// https://github.com/microsoft/vscode/issues/162950
|
||||||
|
|
||||||
|
export type SingleOrMany<T> = T[] | T;
|
||||||
|
|
||||||
export interface TerminalQuickFixProvider {
|
export interface TerminalQuickFixProvider {
|
||||||
/**
|
/**
|
||||||
* Provides terminal quick fixes
|
* Provides terminal quick fixes
|
||||||
|
@ -14,7 +16,7 @@ declare module 'vscode' {
|
||||||
* @param token A cancellation token indicating the result is no longer needed
|
* @param token A cancellation token indicating the result is no longer needed
|
||||||
* @return Terminal quick fix(es) if any
|
* @return Terminal quick fix(es) if any
|
||||||
*/
|
*/
|
||||||
provideTerminalQuickFixes(commandMatchResult: TerminalCommandMatchResult, token: CancellationToken): ProviderResult<(TerminalQuickFixCommand | TerminalQuickFixOpener)[] | TerminalQuickFixCommand | TerminalQuickFixOpener>;
|
provideTerminalQuickFixes(commandMatchResult: TerminalCommandMatchResult, token: CancellationToken): ProviderResult<SingleOrMany<TerminalQuickFixExecuteTerminalCommand | TerminalQuickFixOpener | Command>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +37,7 @@ declare module 'vscode' {
|
||||||
export function registerTerminalQuickFixProvider(id: string, provider: TerminalQuickFixProvider): Disposable;
|
export function registerTerminalQuickFixProvider(id: string, provider: TerminalQuickFixProvider): Disposable;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TerminalQuickFixCommand {
|
export class TerminalQuickFixExecuteTerminalCommand {
|
||||||
/**
|
/**
|
||||||
* The terminal command to run
|
* The terminal command to run
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue