Skip to content

Commit

Permalink
start #45407
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Aug 16, 2021
1 parent 132e88d commit a869f86
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/vs/platform/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ export interface ICreateContributedTerminalProfileOptions {
isSplitTerminal?: boolean;
}

export const enum TerminalLocation {
TerminalView = 'view',
Editor = 'editor'
export enum TerminalLocation {
Panel = 0,
Editor = 1,
}

export type TerminalIcon = ThemeIcon | URI | { light: URI; dark: URI };
Expand Down
34 changes: 34 additions & 0 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,40 @@ declare module 'vscode' {
readonly state: TerminalState;
}

export interface TerminalOptions {
location?: TerminalLocation | TerminalEditorLocationOptions | TerminalSplitLocationOptions;
}

export enum TerminalLocation {
Panel = 0,
Editor = 1,
}

export interface TerminalEditorLocationOptions {
/**
* A view column in which the {@link Terminal terminal} should be shown in the editor area.
* Use {@link ViewColumn.Active active} to open in the active editor group, other values are
* adjusted to be `Min(column, columnCount + 1)`, the
* {@link ViewColumn.Active active}-column is not adjusted. Use
* {@linkcode ViewColumn.Beside} to open the editor to the side of the currently active one.
*/
viewColumn: ViewColumn;
/**
* An optional flag that when `true` will stop the {@link Terminal} from taking focus.
*/
preserveFocus?: boolean;
}

export interface TerminalSplitLocationOptions {
/**
* The parent terminal to split this terminal beside. This works whether the parent terminal
* is in the panel or the editor area.
*/
parentTerminal: Terminal;

// TODO: Do we need to specify a side?
}

/**
* An event representing a change in a {@link Terminal.state terminal's state}.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
if ('pty' in nameOrOptions) {
return extHostTerminalService.createExtensionTerminal(nameOrOptions);
}
if (nameOrOptions.location) {
checkProposedApiEnabled(extension);
}
return extHostTerminalService.createTerminalFromOptions(nameOrOptions);
}
return extHostTerminalService.createTerminal(nameOrOptions, shellPath, shellArgs);
Expand Down Expand Up @@ -1234,6 +1237,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
TaskRevealKind: extHostTypes.TaskRevealKind,
TaskScope: extHostTypes.TaskScope,
TerminalLink: extHostTypes.TerminalLink,
TerminalLocation: extHostTypes.TerminalLocation,
TerminalProfile: extHostTypes.TerminalProfile,
TextDocumentSaveReason: extHostTypes.TextDocumentSaveReason,
TextEdit: extHostTypes.TextEdit,
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import { createExtHostContextProxyIdentifier as createExtId, createMainContextPr
import { CandidatePort } from 'vs/workbench/services/remote/common/remoteExplorerService';
import * as search from 'vs/workbench/services/search/common/search';
import * as statusbar from 'vs/workbench/services/statusbar/common/statusbar';
import { TerminalEditorLocationOptions, TerminalSplitLocationOptions } from 'vscode';

export interface IEnvironment {
isExtensionDevelopmentDebug: boolean;
Expand Down Expand Up @@ -487,6 +488,7 @@ export interface TerminalLaunchConfig {
useShellEnvironment?: boolean;
isSplitTerminal?: boolean;
target?: TerminalLocation;
location?: TerminalLocation | TerminalEditorLocationOptions | TerminalSplitLocationOptions;
}

export interface MainThreadTerminalServiceShape extends IDisposable {
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/api/common/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ export class ExtHostTerminal {
isExtensionOwnedTerminal: true,
useShellEnvironment: withNullAsUndefined(internalOptions?.useShellEnvironment),
isSplitTerminal: internalOptions?.isSplitTerminal,
target: internalOptions?.target
target: internalOptions?.target,
location: withNullAsUndefined(options.location)
});
}

Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/api/common/extHostTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1735,6 +1735,11 @@ export class TerminalLink implements vscode.TerminalLink {
}
}

export enum TerminalLocation {
Panel = 0,
Editor = 1,
}

export class TerminalProfile implements vscode.TerminalProfile {
constructor(
public options: vscode.TerminalOptions | vscode.ExtensionTerminalOptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export function registerTerminalActions() {
async run(accessor: ServicesAccessor) {
const terminalService = accessor.get(ITerminalService);
const terminalGroupService = accessor.get(ITerminalGroupService);
const instance = terminalService.activeInstance || await terminalService.createTerminal({ target: TerminalLocation.TerminalView });
const instance = terminalService.activeInstance || await terminalService.createTerminal({ target: TerminalLocation.Panel });
if (!instance) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { IEditorOptions } from 'vs/platform/editor/common/editor';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { TerminalLocation } from 'vs/platform/terminal/common/terminal';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { IEditorOpenContext } from 'vs/workbench/common/editor';
Expand All @@ -32,6 +31,7 @@ import { BrowserFeatures } from 'vs/base/browser/canIUse';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { openContextMenu } from 'vs/workbench/contrib/terminal/browser/terminalContextMenu';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { TerminalLocation } from 'vs/platform/terminal/common/terminal';

const findWidgetSelector = '.simple-find-part-wrapper';

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/terminal/browser/terminalMenus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ export function getTerminalActionBarArgs(target: TerminalLocation, profiles: ITe
const primaryAction = instantiationService.createInstance(
MenuItemAction,
{
id: target === TerminalLocation.TerminalView ? TerminalCommandId.New : TerminalCommandId.CreateTerminalEditor,
id: target === TerminalLocation.Panel ? TerminalCommandId.New : TerminalCommandId.CreateTerminalEditor,
title: localize('terminal.new', "New Terminal"),
icon: Codicon.plus
},
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/contrib/terminal/browser/terminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export class TerminalService implements ITerminalService {
// create group and terminal
terminalInstance = await this.createTerminal({
config: { attachPersistentProcess: terminalLayout.terminal! },
target: TerminalLocation.TerminalView
target: TerminalLocation.Panel
});
group = this._terminalGroupService.getGroupForInstance(terminalInstance);
if (groupLayout.isActive) {
Expand Down Expand Up @@ -646,7 +646,7 @@ export class TerminalService implements ITerminalService {
await this._localTerminalsInitPromise;
}
if (this._terminalGroupService.groups.length === 0 && this.isProcessSupportRegistered) {
this.createTerminal({ target: TerminalLocation.TerminalView });
this.createTerminal({ target: TerminalLocation.Panel });
}
}

Expand Down Expand Up @@ -679,7 +679,7 @@ export class TerminalService implements ITerminalService {
if (source.target !== TerminalLocation.Editor) {
return;
}
source.target = TerminalLocation.TerminalView;
source.target = TerminalLocation.Panel;

let group: ITerminalGroup | undefined;
if (target) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {
this.onMouseDblClick(async e => {
const focus = this.getFocus();
if (focus.length === 0) {
const instance = await this._terminalService.createTerminal({ target: TerminalLocation.TerminalView });
const instance = await this._terminalService.createTerminal({ target: TerminalLocation.Panel });
this._terminalGroupService.setActiveInstance(instance);
await instance.focusWhenReady();
}
Expand Down
9 changes: 4 additions & 5 deletions 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({ target: TerminalLocation.TerminalView });
this._terminalService.createTerminal({ target: TerminalLocation.Panel });
}
} else {
this._terminalsInitialized = true;
Expand Down Expand Up @@ -204,8 +204,7 @@ export class TerminalViewPane extends ViewPane {
this._tabButtons.dispose();
}

const actions = getTerminalActionBarArgs(TerminalLocation.TerminalView, this._terminalService.availableProfiles, this._getDefaultProfileName(), this._terminalContributionService.terminalProfiles, this._instantiationService, this._terminalService, this._contextKeyService, this._commandService, this._dropdownMenu);

const actions = getTerminalActionBarArgs(TerminalLocation.Panel, this._terminalService.availableProfiles, this._getDefaultProfileName(), this._terminalContributionService.terminalProfiles, this._instantiationService, this._terminalService, this._contextKeyService, this._commandService, this._dropdownMenu);
this._tabButtons = new DropdownWithPrimaryActionViewItem(actions.primaryAction, actions.dropdownAction, actions.dropdownMenuActions, actions.className, this._contextMenuService, {}, this._keybindingService, this._notificationService, this._contextKeyService);
this._updateTabActionBar(this._terminalService.availableProfiles);
return this._tabButtons;
Expand All @@ -229,7 +228,7 @@ export class TerminalViewPane extends ViewPane {
}

private _updateTabActionBar(profiles: ITerminalProfile[]): void {
const actions = getTerminalActionBarArgs(TerminalLocation.TerminalView, profiles, this._getDefaultProfileName(), this._terminalContributionService.terminalProfiles, this._instantiationService, this._terminalService, this._contextKeyService, this._commandService, this._dropdownMenu);
const actions = getTerminalActionBarArgs(TerminalLocation.Panel, profiles, this._getDefaultProfileName(), this._terminalContributionService.terminalProfiles, this._instantiationService, this._terminalService, this._contextKeyService, this._commandService, this._dropdownMenu);
this._tabButtons?.update(actions.dropdownAction, actions.dropdownMenuActions);
}

Expand Down Expand Up @@ -388,7 +387,7 @@ class SingleTerminalTabActionViewItem extends MenuEntryActionViewItem {

override async onClick(event: MouseEvent): Promise<void> {
if (event.altKey && this._menuItemAction.alt) {
this._commandService.executeCommand(this._menuItemAction.alt.id, { target: TerminalLocation.TerminalView } as ICreateTerminalOptions);
this._commandService.executeCommand(this._menuItemAction.alt.id, { target: TerminalLocation.Panel } as ICreateTerminalOptions);
} else {
this._openContextMenu();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const terminalConfiguration: IConfigurationNode = {
},
[TerminalSettingId.DefaultLocation]: {
type: 'string',
enum: [TerminalLocation.Editor, TerminalLocation.TerminalView],
enum: [TerminalLocation.Editor, TerminalLocation.Panel],
enumDescriptions: [
localize('terminal.integrated.defaultLocation.editor', "Create terminals in the editor"),
localize('terminal.integrated.defaultLocation.view', "Create terminals in the terminal view")
Expand Down

0 comments on commit a869f86

Please sign in to comment.