mirror of
https://github.com/Microsoft/vscode
synced 2024-08-25 03:56:03 +00:00
de-duplicate isSplitTerminal/sideGroup (#129272)
This commit is contained in:
parent
25bc9a1b3b
commit
dbd709ceb5
|
@ -402,18 +402,14 @@ export interface ICreateTerminalOptions {
|
|||
*/
|
||||
target?: TerminalLocation;
|
||||
/**
|
||||
* Create the editor terminal in beside the current editor.
|
||||
* Creates a split terminal without requiring a terminal instance to split, for example when splitting
|
||||
* a terminal editor
|
||||
*/
|
||||
sideGroup?: boolean;
|
||||
forceSplit?: boolean;
|
||||
/**
|
||||
* The terminal's resource, passed when the terminal has moved windows.
|
||||
*/
|
||||
resource?: URI;
|
||||
|
||||
/**
|
||||
* Whether or not this terminal should be a split
|
||||
*/
|
||||
isSplitTerminal?: boolean;
|
||||
}
|
||||
|
||||
export interface ICreateContributedTerminalProfileOptions {
|
||||
|
|
|
@ -141,7 +141,7 @@ export interface ITerminalService extends ITerminalInstanceHost {
|
|||
|
||||
|
||||
getActiveOrCreateInstance(): Promise<ITerminalInstance>;
|
||||
splitInstance(instance: ITerminalInstance, shell?: ITerminalProfile | IShellLaunchConfig | IExtensionTerminalProfile | undefined, cwd?: string | URI): Promise<ITerminalInstance | null>;
|
||||
splitInstance(instance: ITerminalInstance, shell?: ITerminalProfile | IShellLaunchConfig | IExtensionTerminalProfile | undefined, cwd?: string | URI): Promise<ITerminalInstance>;
|
||||
moveToEditor(source: ITerminalInstance): void;
|
||||
moveToTerminalView(source?: ITerminalInstance | URI): Promise<void>;
|
||||
getOffProcessTerminalService(): IOffProcessTerminalService | undefined;
|
||||
|
|
|
@ -256,7 +256,7 @@ export function registerTerminalActions() {
|
|||
const terminalService = accessor.get(ITerminalService);
|
||||
const instance = await terminalService.createTerminal({
|
||||
target: TerminalLocation.Editor,
|
||||
sideGroup: true
|
||||
forceSplit: true
|
||||
});
|
||||
instance.focusWhenReady();
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ export class TerminalEditor extends EditorPane {
|
|||
id: contributed.id,
|
||||
title: contributed.title.replace(/[\n\r\t]/g, '')
|
||||
},
|
||||
isSplitTerminal: true,
|
||||
forceSplit: true,
|
||||
target: TerminalLocation.Editor
|
||||
})));
|
||||
}
|
||||
|
|
|
@ -624,7 +624,7 @@ export class TerminalService implements ITerminalService {
|
|||
}
|
||||
}
|
||||
|
||||
async splitInstance(instanceToSplit: ITerminalInstance, shell?: IShellLaunchConfig, cwd?: string | URI): Promise<ITerminalInstance | null> {
|
||||
async splitInstance(instanceToSplit: ITerminalInstance, shell?: IShellLaunchConfig, cwd?: string | URI): Promise<ITerminalInstance> {
|
||||
const shellLaunchConfig = this._convertProfileToShellLaunchConfig(shell);
|
||||
|
||||
const contributedDefaultProfile = await this._getContributedDefaultProfile(shellLaunchConfig);
|
||||
|
@ -652,7 +652,7 @@ export class TerminalService implements ITerminalService {
|
|||
default:
|
||||
const group = this._terminalGroupService.getGroupForInstance(instanceToSplit);
|
||||
if (!group) {
|
||||
return null;
|
||||
throw new Error(`Cannot split a terminal without a group ${instanceToSplit}`);
|
||||
}
|
||||
instance = group.split(shellLaunchConfig);
|
||||
break;
|
||||
|
@ -1113,7 +1113,7 @@ export class TerminalService implements ITerminalService {
|
|||
} else if (Object.entries(options).length > 2) {
|
||||
return false;
|
||||
}
|
||||
return Array.from(Object.keys(options)).filter(k => k !== 'target' && k !== 'isSplitTerminal').length === 0;
|
||||
return Array.from(Object.keys(options)).filter(k => k !== 'target' && k !== 'forceSplit').length === 0;
|
||||
}
|
||||
|
||||
async createTerminal(options?: ICreateTerminalOptions): Promise<ITerminalInstance> {
|
||||
|
@ -1133,7 +1133,7 @@ export class TerminalService implements ITerminalService {
|
|||
// Launch the contributed profile
|
||||
if (contributedProfile) {
|
||||
await this._createContributedTerminalProfile(contributedProfile.extensionIdentifier, contributedProfile.id, {
|
||||
isSplitTerminal: options?.isSplitTerminal || false,
|
||||
isSplitTerminal: options?.forceSplit || false,
|
||||
icon: contributedProfile.icon,
|
||||
target: options?.target
|
||||
});
|
||||
|
@ -1166,7 +1166,7 @@ export class TerminalService implements ITerminalService {
|
|||
if (target === TerminalLocation.Editor) {
|
||||
instance = this._terminalInstanceService.createInstance(shellLaunchConfig, undefined, options?.resource);
|
||||
instance.target = TerminalLocation.Editor;
|
||||
this._terminalEditorService.openEditor(instance, options?.sideGroup);
|
||||
this._terminalEditorService.openEditor(instance, options?.forceSplit);
|
||||
} else {
|
||||
// TODO: pass resource?
|
||||
const group = this._terminalGroupService.createGroup(shellLaunchConfig);
|
||||
|
|
|
@ -258,7 +258,7 @@ export class TerminalViewPane extends ViewPane {
|
|||
id: contributed.id,
|
||||
title: contributed.title.replace(/[\n\r\t]/g, '')
|
||||
},
|
||||
isSplitTerminal: false
|
||||
forceSplit: false
|
||||
})));
|
||||
submenuActions.push(new Action(TerminalCommandId.NewWithProfile, contributed.title.replace(/[\n\r\t]/g, ''), undefined, true, () => this._terminalService.createTerminal({
|
||||
config: {
|
||||
|
@ -266,7 +266,7 @@ export class TerminalViewPane extends ViewPane {
|
|||
id: contributed.id,
|
||||
title: contributed.title.replace(/[\n\r\t]/g, '')
|
||||
},
|
||||
isSplitTerminal: true
|
||||
forceSplit: true
|
||||
})));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue