Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge authored Jun 25, 2021
1 parent 21d6aa4 commit 61097e4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
28 changes: 18 additions & 10 deletions src/vs/workbench/contrib/terminal/browser/terminalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function registerTerminalActions() {
async run(accessor: ServicesAccessor) {
const terminalService = accessor.get(ITerminalService);
if (terminalService.isProcessSupportRegistered) {
const instance = terminalService.createTerminal();
const instance = terminalService.createTerminal({ target: terminalService.configHelper.config.defaultLocation });
if (!instance) {
return;
}
Expand Down Expand Up @@ -425,7 +425,7 @@ export function registerTerminalActions() {
}
async run(accessor: ServicesAccessor) {
const terminalService = accessor.get(ITerminalService);
const instance = terminalService.getActiveOrCreateInstance();
const instance = terminalService.activeInstance || terminalService.createTerminal({ target: TerminalLocation.TerminalView });
if (!instance) {
return;
}
Expand Down Expand Up @@ -1611,16 +1611,25 @@ export function registerTerminalActions() {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKTICK,
mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.US_BACKTICK },
weight: KeybindingWeight.WorkbenchContrib
},
description: {
description: 'workbench.action.terminal.new',
args: [{
name: 'eventOrOptions',
schema: {
type: 'object'
}
}]
}
});
}
async run(accessor: ServicesAccessor, event: unknown) {
async run(accessor: ServicesAccessor, eventOrOptions: MouseEvent | ICreateTerminalOptions | undefined) {
const terminalService = accessor.get(ITerminalService);
const terminalGroupService = accessor.get(ITerminalGroupService);
const workspaceContextService = accessor.get(IWorkspaceContextService);
const commandService = accessor.get(ICommandService);
const folders = workspaceContextService.getWorkspace().folders;
if (event instanceof MouseEvent && (event.altKey || event.ctrlKey)) {
if (eventOrOptions && eventOrOptions instanceof MouseEvent && (eventOrOptions.altKey || eventOrOptions.ctrlKey)) {
const activeInstance = terminalService.activeInstance;
if (activeInstance) {
const cwd = await getCwdForSplit(terminalService.configHelper, activeInstance);
Expand All @@ -1630,11 +1639,13 @@ export function registerTerminalActions() {
}

if (terminalService.isProcessSupportRegistered) {
eventOrOptions = !eventOrOptions || eventOrOptions instanceof MouseEvent ? {} : eventOrOptions;
eventOrOptions.target = eventOrOptions.target || terminalService.configHelper.config.defaultLocation;
let instance: ITerminalInstance | undefined;
if (folders.length <= 1) {
// Allow terminal service to handle the path when there is only a
// single root
instance = terminalService.createTerminal();
instance = terminalService.createTerminal(eventOrOptions);
} else {
const options: IPickOptions<IQuickPickItem> = {
placeHolder: localize('workbench.action.terminal.newWorkspacePlaceholder', "Select current working directory for new terminal")
Expand All @@ -1644,11 +1655,8 @@ export function registerTerminalActions() {
// Don't create the instance if the workspace picker was canceled
return;
}
instance = terminalService.createTerminal(
{
cwd: workspace.uri
}
);
eventOrOptions.cwd = workspace.uri;
instance = terminalService.createTerminal(eventOrOptions);
}
terminalService.setActiveInstance(instance);
}
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/contrib/terminal/browser/terminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,7 @@ export class TerminalService implements ITerminalService {
}

createTerminal(options?: ICreateTerminalOptions): ITerminalInstance {
console.log(options);
const shellLaunchConfig = this._convertProfileToShellLaunchConfig(options?.config || options);

if (options?.cwd) {
Expand All @@ -1044,7 +1045,7 @@ export class TerminalService implements ITerminalService {
this._evaluateLocalCwd(shellLaunchConfig);

let instance: ITerminalInstance;
if (options?.target === TerminalLocation.Editor || this.configHelper.config.defaultLocation === TerminalLocation.Editor) {
if (options?.target === TerminalLocation.Editor) {
instance = this.createInstance(shellLaunchConfig);
instance.target = TerminalLocation.Editor;
this._terminalEditorService.openEditor(instance);
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/terminal/browser/terminalView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class TerminalViewPane extends ViewPane {
if (this._terminalService.isProcessSupportRegistered) {
if (this._terminalsInitialized) {
if (!hadTerminals) {
this._terminalService.createTerminal();
this._terminalService.createTerminal({ target: TerminalLocation.TerminalView });
}
} else {
this._terminalsInitialized = true;
Expand Down

0 comments on commit 61097e4

Please sign in to comment.