Add location support for newWithProfile command

Fixes #208306
This commit is contained in:
Daniel Imms 2024-03-22 09:53:54 -07:00
parent c4e35f0f03
commit 8fc2765204
No known key found for this signature in database
GPG key ID: E5CF412B63651C69

View file

@ -1776,6 +1776,15 @@ export function refreshTerminalActions(detectedProfiles: ITerminalProfile[]) {
type: 'string',
enum: profileEnum.values,
markdownEnumDescriptions: profileEnum.markdownDescriptions
},
location: {
description: localize('newWithProfile.location', "Where to create the terminal"),
type: 'string',
enum: ['view', 'editor'],
enumDescriptions: [
localize('newWithProfile.location.view', 'Create the terminal in the terminal view'),
localize('newWithProfile.location.editor', 'Create the terminal in the editor'),
]
}
}
}
@ -1783,7 +1792,11 @@ export function refreshTerminalActions(detectedProfiles: ITerminalProfile[]) {
},
});
}
async run(accessor: ServicesAccessor, eventOrOptionsOrProfile: MouseEvent | ICreateTerminalOptions | ITerminalProfile | { profileName: string } | undefined, profile?: ITerminalProfile) {
async run(
accessor: ServicesAccessor,
eventOrOptionsOrProfile: MouseEvent | ICreateTerminalOptions | ITerminalProfile | { profileName: string; location?: 'view' | 'editor' | unknown } | undefined,
profile?: ITerminalProfile
) {
const c = getTerminalServices(accessor);
const workspaceContextService = accessor.get(IWorkspaceContextService);
const commandService = accessor.get(ICommandService);
@ -1799,6 +1812,12 @@ export function refreshTerminalActions(detectedProfiles: ITerminalProfile[]) {
throw new Error(`Could not find terminal profile "${eventOrOptionsOrProfile.profileName}"`);
}
options = { config };
if ('location' in eventOrOptionsOrProfile) {
switch (eventOrOptionsOrProfile.location) {
case 'editor': options.location = TerminalLocation.Editor; break;
case 'view': options.location = TerminalLocation.Panel; break;
}
}
} else if (isMouseEvent(eventOrOptionsOrProfile) || isPointerEvent(eventOrOptionsOrProfile) || isKeyboardEvent(eventOrOptionsOrProfile)) {
event = eventOrOptionsOrProfile;
options = profile ? { config: profile } : undefined;