fix #131404
This commit is contained in:
parent
2da60a8a4a
commit
1c4c7c29fa
|
@ -398,8 +398,8 @@ export interface ICreateContributedTerminalProfileOptions {
|
|||
}
|
||||
|
||||
export enum TerminalLocation {
|
||||
Panel = 0,
|
||||
Editor = 1
|
||||
Panel = 1,
|
||||
Editor = 2
|
||||
}
|
||||
|
||||
export const enum TerminalLocationString {
|
||||
|
|
4
src/vs/vscode.proposed.d.ts
vendored
4
src/vs/vscode.proposed.d.ts
vendored
|
@ -926,8 +926,8 @@ declare module 'vscode' {
|
|||
}
|
||||
|
||||
export enum TerminalLocation {
|
||||
Panel = 0,
|
||||
Editor = 1,
|
||||
Panel = 1,
|
||||
Editor = 2,
|
||||
}
|
||||
|
||||
export interface TerminalEditorLocationOptions {
|
||||
|
|
|
@ -174,7 +174,7 @@ export class ExtHostTerminal {
|
|||
return this._id;
|
||||
}
|
||||
|
||||
private _serializeParentTerminal(location?: TerminalLocation | vscode.TerminalEditorLocationOptions | vscode.TerminalSplitLocationOptions | { splitActiveTerminal: boolean }, parentTerminal?: ExtHostTerminalIdentifier, internalLocation?: TerminalLocation | { viewColumn: number, preserveState?: boolean } | { splitActiveTerminal: boolean }): TerminalLocation | vscode.TerminalEditorLocationOptions | { parentTerminal: ExtHostTerminalIdentifier } | { splitActiveTerminal: boolean, location?: TerminalLocation } | vscode.TerminalEditorLocationOptions | undefined {
|
||||
private _serializeParentTerminal(location?: TerminalLocation | vscode.TerminalEditorLocationOptions | vscode.TerminalSplitLocationOptions | { splitActiveTerminal: boolean }, parentTerminal?: ExtHostTerminalIdentifier, internalLocation?: TerminalLocation | { viewColumn: number, preserveState?: boolean } | { splitActiveTerminal: boolean }): TerminalLocation | vscode.TerminalEditorLocationOptions | { parentTerminal: ExtHostTerminalIdentifier } | { splitActiveTerminal: boolean } | vscode.TerminalEditorLocationOptions | undefined {
|
||||
if (typeof location === 'object' && 'parentTerminal' in location) {
|
||||
return parentTerminal ? { parentTerminal } : undefined;
|
||||
} else if (internalLocation) {
|
||||
|
|
|
@ -188,6 +188,7 @@ export interface ITerminalService extends ITerminalInstanceHost {
|
|||
getFindHost(instance?: ITerminalInstance): ITerminalFindHost;
|
||||
|
||||
getDefaultProfileName(): string;
|
||||
resolveLocation(location?: ITerminalLocationOptions): TerminalLocation | undefined
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1661,7 +1661,7 @@ export function registerTerminalActions() {
|
|||
|
||||
if (terminalService.isProcessSupportRegistered) {
|
||||
eventOrOptions = !eventOrOptions || eventOrOptions instanceof MouseEvent ? {} : eventOrOptions;
|
||||
eventOrOptions.location = eventOrOptions.location || terminalService.defaultLocation;
|
||||
|
||||
let instance: ITerminalInstance | undefined;
|
||||
if (folders.length <= 1) {
|
||||
// Allow terminal service to handle the path when there is only a
|
||||
|
@ -2004,8 +2004,12 @@ export function validateTerminalName(name: string): { content: string, severity:
|
|||
}
|
||||
|
||||
function convertOptionsOrProfileToOptions(optionsOrProfile?: ICreateTerminalOptions | ITerminalProfile): ICreateTerminalOptions | undefined {
|
||||
if (typeof optionsOrProfile === 'object' && 'profileName' in optionsOrProfile) {
|
||||
return { config: optionsOrProfile as ITerminalProfile };
|
||||
if (typeof optionsOrProfile === 'object') {
|
||||
if ('profileName' in optionsOrProfile) {
|
||||
return { config: optionsOrProfile as ITerminalProfile, location: (optionsOrProfile as ICreateTerminalOptions).location };
|
||||
} else if ('location' in optionsOrProfile) {
|
||||
return { location: (optionsOrProfile as ICreateTerminalOptions).location };
|
||||
}
|
||||
}
|
||||
return optionsOrProfile;
|
||||
}
|
||||
|
|
|
@ -611,7 +611,7 @@ export function getTerminalActionBarArgs(location: ITerminalLocationOptions, pro
|
|||
for (const contributed of contributedProfiles) {
|
||||
const isDefault = contributed.title === defaultProfileName;
|
||||
const title = isDefault ? localize('defaultTerminalProfile', "{0} (Default)", contributed.title.replace(/[\n\r\t]/g, '')) : contributed.title.replace(/[\n\r\t]/g, '');
|
||||
dropdownActions.push(new Action(TerminalCommandId.NewWithProfile, title, undefined, true, () => terminalService.createTerminal({
|
||||
dropdownActions.push(new Action('contributed', title, undefined, true, () => terminalService.createTerminal({
|
||||
config: {
|
||||
extensionIdentifier: contributed.extensionIdentifier,
|
||||
id: contributed.id,
|
||||
|
@ -620,7 +620,7 @@ export function getTerminalActionBarArgs(location: ITerminalLocationOptions, pro
|
|||
location
|
||||
})));
|
||||
const splitLocation = location === TerminalLocation.Editor ? { viewColumn: SIDE_GROUP } : { splitActiveTerminal: true };
|
||||
submenuActions.push(new Action(TerminalCommandId.NewWithProfile, title, undefined, true, () => terminalService.createTerminal({
|
||||
submenuActions.push(new Action('contributed-split', title, undefined, true, () => terminalService.createTerminal({
|
||||
config: {
|
||||
extensionIdentifier: contributed.extensionIdentifier,
|
||||
id: contributed.id,
|
||||
|
@ -656,10 +656,11 @@ export function getTerminalActionBarArgs(location: ITerminalLocationOptions, pro
|
|||
submenuActions.unshift(defaultSubmenuProfileAction);
|
||||
}
|
||||
|
||||
const primaryActionLocation = terminalService.resolveLocation(location);
|
||||
const primaryAction = instantiationService.createInstance(
|
||||
MenuItemAction,
|
||||
{
|
||||
id: location === TerminalLocation.Panel ? TerminalCommandId.New : TerminalCommandId.CreateTerminalEditor,
|
||||
id: primaryActionLocation === TerminalLocation.Editor ? TerminalCommandId.CreateTerminalEditor : TerminalCommandId.New,
|
||||
title: localize('terminal.new', "New Terminal"),
|
||||
icon: Codicon.plus
|
||||
},
|
||||
|
@ -670,9 +671,9 @@ export function getTerminalActionBarArgs(location: ITerminalLocationOptions, pro
|
|||
},
|
||||
{
|
||||
shouldForwardArgs: true,
|
||||
arg: { location } as ICreateTerminalOptions,
|
||||
arg: { location: primaryActionLocation } as ICreateTerminalOptions,
|
||||
});
|
||||
|
||||
const dropdownAction = new Action('refresh profiles', 'Launch Profile...', 'codicon-chevron-down', true);
|
||||
return { primaryAction, dropdownAction, dropdownMenuActions: dropdownActions, className: 'terminal-tab-actions' };
|
||||
return { primaryAction, dropdownAction, dropdownMenuActions: dropdownActions, className: `terminal-tab-actions-${terminalService.resolveLocation(location)}` };
|
||||
}
|
||||
|
|
|
@ -1156,7 +1156,7 @@ export class TerminalService implements ITerminalService {
|
|||
|
||||
// Launch the contributed profile
|
||||
if (contributedProfile) {
|
||||
const resolvedLocation = this._resolveLocation(options?.location);
|
||||
const resolvedLocation = this.resolveLocation(options?.location);
|
||||
const splitActiveTerminal = typeof options?.location === 'object' && 'splitActiveTerminal' in options.location ? options.location.splitActiveTerminal : false;
|
||||
const location = splitActiveTerminal ? resolvedLocation === TerminalLocation.Editor ? { viewColumn: SIDE_GROUP } : { splitActiveTerminal: true } : resolvedLocation;
|
||||
await this._createContributedTerminalProfile(contributedProfile.extensionIdentifier, contributedProfile.id, {
|
||||
|
@ -1187,9 +1187,8 @@ export class TerminalService implements ITerminalService {
|
|||
}
|
||||
|
||||
this._evaluateLocalCwd(shellLaunchConfig);
|
||||
const location = this._resolveLocation(options?.location) || this.defaultLocation;
|
||||
const location = this.resolveLocation(options?.location) || this.defaultLocation;
|
||||
const parent = this._getSplitParent(options?.location);
|
||||
|
||||
if (parent) {
|
||||
return this._splitTerminal(shellLaunchConfig, location, parent);
|
||||
} else {
|
||||
|
@ -1235,16 +1234,16 @@ export class TerminalService implements ITerminalService {
|
|||
return instance;
|
||||
}
|
||||
|
||||
private _resolveLocation(location?: ITerminalLocationOptions): TerminalLocation | undefined {
|
||||
if (!location) {
|
||||
return location;
|
||||
} else if (typeof location === 'object') {
|
||||
resolveLocation(location?: ITerminalLocationOptions): TerminalLocation | undefined {
|
||||
if (location && typeof location === 'object') {
|
||||
if ('parentTerminal' in location) {
|
||||
return location.parentTerminal.target;
|
||||
// since we don't set the target unless it's an editor terminal, this is necessary
|
||||
return !location.parentTerminal.target ? TerminalLocation.Panel : location.parentTerminal.target;
|
||||
} else if ('viewColumn' in location) {
|
||||
return TerminalLocation.Editor;
|
||||
} else if ('splitActiveTerminal' in location) {
|
||||
return this._activeInstance?.target || this.defaultLocation;
|
||||
// since we don't set the target unless it's an editor terminal, this is necessary
|
||||
return !this._activeInstance?.target ? TerminalLocation.Panel : this._activeInstance?.target;
|
||||
}
|
||||
}
|
||||
return location;
|
||||
|
|
Loading…
Reference in a new issue