Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 89de2bd
Author: meganrogge <[email protected]>
Date:   Tue Jun 15 11:43:13 2021 -0700

    dispose of instance on close of editor

commit 583f348
Author: meganrogge <[email protected]>
Date:   Tue Jun 15 11:21:02 2021 -0700

    get unique terminal instances to work
    Co-authored-by: Daniel Imms <[email protected]>

commit 7fa7440
Author: meganrogge <[email protected]>
Date:   Tue Jun 15 09:44:29 2021 -0700

    call attachToElement in setInput

commit 5416f75
Author: Benjamin Pasero <[email protected]>
Date:   Tue Jun 15 15:49:49 2021 +0200

    :chore: - ignore unhandled promise cancel rejections

    //cc @joaomoreno @alexdima @sbatten

commit 55c6ee0
Author: Benjamin Pasero <[email protected]>
Date:   Tue Jun 15 15:45:10 2021 +0200

    .

commit 25fe69f
Author: Benjamin Pasero <[email protected]>
Date:   Tue Jun 15 15:40:20 2021 +0200

    fix emmet test integration path

commit f4bc7d3
Author: Martin Aeschlimann <[email protected]>
Date:   Tue Jun 15 15:34:54 2021 +0200

    Use custom hover for all status bar entries

commit 5b79dcf
Author: Martin Aeschlimann <[email protected]>
Date:   Tue Jun 15 15:17:12 2021 +0200

    MarkdownString for StatusBarItem.tooltip. For #126258

commit 0a0c8f3
Author: João Moreno <[email protected]>
Date:   Tue Jun 15 15:29:36 2021 +0200

    Revert "switch to generic pool"

    This reverts commit 6495c05.

commit 19f9cd4
Author: Johannes Rieken <[email protected]>
Date:   Tue Jun 15 15:24:09 2021 +0200

    fix #125942

commit c6945f1
Author: João Moreno <[email protected]>
Date:   Tue Jun 15 15:15:41 2021 +0200

    fix integration browser tests

commit e99f791
Author: Sandeep Somavarapu <[email protected]>
Date:   Mon Jun 14 23:29:27 2021 +0200

    - move writing user configuration to main process
    - safe guard read from writing in parallel from other windows

commit 4a840ce
Author: Megan Rogge <[email protected]>
Date:   Tue Jun 15 07:31:23 2021 -0500

    finalize terminal iconPath (#125783)

commit 5745873
Author: Alex Ross <[email protected]>
Date:   Tue Jun 15 14:08:59 2021 +0200

    Fix timing issue where port detection can fail to start

commit d47661d
Author: João Moreno <[email protected]>
Date:   Tue Jun 15 14:07:35 2021 +0200

    skip the entire notebook test suite so Code isn't even launched

commit 41c7c25
Author: Alex Ross <[email protected]>
Date:   Tue Jun 15 13:20:11 2021 +0200

    Fix task close=false
    Fixes #126352

commit 5d70c90
Author: Ladislau Szomoru <[email protected]>
Date:   Tue Jun 15 13:08:59 2021 +0200

    💄 clean-up workspace contribution

commit 537b1f0
Author: meganrogge <[email protected]>
Date:   Tue Jun 15 07:00:12 2021 -0700

    add icon manager

commit e97953a
Author: Daniel Imms <[email protected]>
Date:   Tue Jun 15 06:57:18 2021 -0700

    Add move to editor command

    Part of #126247

commit 56501c5
Author: Daniel Imms <[email protected]>
Date:   Tue Jun 15 06:50:21 2021 -0700

    Disable serialization by returning undefined

commit 52d8d8e
Merge: 46877c9 f569691
Author: Daniel Imms <[email protected]>
Date:   Tue Jun 15 06:43:37 2021 -0700

    Merge pull request #126383 from microsoft/merogge/terminalEditor_tyriar

    Terminal editor lifecycle work

commit f569691
Merge: a215c79 46877c9
Author: Daniel Imms <[email protected]>
Date:   Tue Jun 15 06:26:45 2021 -0700

    Merge remote-tracking branch 'origin/merogge/terminalEditor' into merogge/terminalEditor_tyriar

commit 46877c9
Author: meganrogge <[email protected]>
Date:   Tue Jun 15 06:16:17 2021 -0700

    fix serialization error

commit a215c79
Author: Daniel Imms <[email protected]>
Date:   Tue Jun 15 06:10:21 2021 -0700

    Move editor creation into new service

commit 4475d84
Author: Daniel Imms <[email protected]>
Date:   Tue Jun 15 05:03:39 2021 -0700

    Create editor terminal in terminal service

commit 86b4336
Author: Daniel Imms <[email protected]>
Date:   Tue Jun 15 04:44:53 2021 -0700

    Make detach return a Promise

    Part of #118276

commit 120f9b8
Author: Daniel Imms <[email protected]>
Date:   Tue Jun 15 04:34:42 2021 -0700

    Change createTerminal signature to use options object

commit 0baba5e
Author: Daniel Imms <[email protected]>
Date:   Tue Jun 15 04:14:27 2021 -0700

    Rename editor to just 'Terminal'

    Other editors that don't actually edit don't have 'Editor' in the name either (eg.
    Running Extensions), so it will be an internal term.

commit 8bb96ce
Author: Daniel Imms <[email protected]>
Date:   Tue Jun 15 04:11:08 2021 -0700

    Inline terminal editor input ID

commit c2304c2
Author: Daniel Imms <[email protected]>
Date:   Tue Jun 15 04:07:57 2021 -0700

    Remove unneeded !

commit 8367f18
Merge: c29d362 9b4f499
Author: Daniel Imms <[email protected]>
Date:   Tue Jun 15 04:05:12 2021 -0700

    Merge remote-tracking branch 'origin/main' into merogge/terminalEditor

commit c29d362
Author: meganrogge <[email protected]>
Date:   Mon Jun 14 19:23:52 2021 -0700

    use terminal instance.resource

commit fb50a7f
Author: meganrogge <[email protected]>
Date:   Mon Jun 14 17:13:51 2021 -0700

    revert some css changes

commit 50b6b81
Author: meganrogge <[email protected]>
Date:   Mon Jun 14 15:53:47 2021 -0700

    add copy and try a few other things

commit 0c226cd
Author: meganrogge <[email protected]>
Date:   Mon Jun 14 13:13:28 2021 -0700

    clean up

commit e4c8b94
Author: meganrogge <[email protected]>
Date:   Mon Jun 14 12:03:05 2021 -0700

    remove unnecessary changes

commit 31bcda4
Author: meganrogge <[email protected]>
Date:   Mon Jun 14 11:45:41 2021 -0700

    add basics for #126244
  • Loading branch information
meganrogge committed Jun 15, 2021
1 parent 79d338b commit 22f216d
Show file tree
Hide file tree
Showing 16 changed files with 432 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/vs/platform/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ export interface ITerminalChildProcess {
/**
* Detach the process from the UI and await reconnect.
*/
detach?(): void;
detach?(): Promise<void>;

/**
* Shutdown the terminal process.
Expand Down
22 changes: 15 additions & 7 deletions src/vs/workbench/contrib/terminal/browser/media/terminal.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,49 @@
.monaco-workbench .pane-body.integrated-terminal .terminal-outer-container,
.monaco-workbench .pane-body.integrated-terminal .terminal-groups-container,
.monaco-workbench .pane-body.integrated-terminal .terminal-group,
.monaco-workbench .pane-body.integrated-terminal .terminal-split-pane {
.monaco-workbench .pane-body.integrated-terminal .terminal-split-pane,
.monaco-workbench .editor-instance .terminal-split-pane,
.monaco-workbench .editor-instance .terminal-outer-container {
height: 100%;
}

.monaco-workbench .editor-instance .terminal-wrapper,
.monaco-workbench .pane-body.integrated-terminal .terminal-wrapper {
display: none;
margin: 0 10px;
bottom: 2px;
}

.monaco-workbench .editor-instance .terminal-wrapper.active,
.monaco-workbench .pane-body.integrated-terminal .terminal-wrapper.active {
display: block;
}

.monaco-workbench .pane-body.integrated-terminal .terminal-wrapper.active {
position: absolute;
top: 0;
}
.monaco-workbench .pane-body.integrated-terminal .terminal-group .monaco-split-view2.horizontal .split-view-view:first-child .terminal-wrapper {
.monaco-workbench .terminal-group .monaco-split-view2.horizontal .split-view-view:first-child .terminal-wrapper {
margin-left: 20px;
}
.monaco-workbench .pane-body.integrated-terminal .terminal-group .monaco-split-view2.horizontal .split-view-view:last-child .terminal-wrapper {
.monaco-workbench .terminal-group .monaco-split-view2.horizontal .split-view-view:last-child .terminal-wrapper {
margin-right: 20px;
}

.monaco-workbench .pane-body.integrated-terminal .xterm a:not(.xterm-invalid-link) {
.monaco-workbench .xterm a:not(.xterm-invalid-link) {
/* To support message box sizing */
position: relative;
}

.monaco-workbench .pane-body.integrated-terminal .terminal-wrapper > div {
.monaco-workbench .terminal-wrapper > div {
height: 100%;
}

.monaco-workbench .pane-body.integrated-terminal .xterm-viewport {
.monaco-workbench .xterm-viewport {
box-sizing: border-box;
margin-right: -10px;
}
.monaco-workbench .pane-body.integrated-terminal .terminal-group .monaco-split-view2.horizontal .split-view-view:last-child .xterm-viewport {
.monaco-workbench .monaco-split-view2.horizontal .split-view-view:last-child .xterm-viewport {
margin-right: -20px;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { registerColors } from 'vs/workbench/contrib/terminal/common/terminalCol
import { setupTerminalCommands } from 'vs/workbench/contrib/terminal/browser/terminalCommands';
import { TerminalService } from 'vs/workbench/contrib/terminal/browser/terminalService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IRemoteTerminalService, ITerminalInstanceService, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
import { IRemoteTerminalService, ITerminalEditorService, ITerminalInstanceService, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneContainer';
import { IQuickAccessRegistry, Extensions as QuickAccessExtensions } from 'vs/platform/quickinput/common/quickAccess';
Expand All @@ -37,9 +37,16 @@ import { isIOS, isWindows } from 'vs/base/common/platform';
import { setupTerminalMenus } from 'vs/workbench/contrib/terminal/browser/terminalMenus';
import { TerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminalInstanceService';
import { registerTerminalPlatformConfiguration } from 'vs/platform/terminal/common/terminalPlatformConfiguration';
import { EditorExtensions, IEditorInputFactoryRegistry } from 'vs/workbench/common/editor';
import { EditorDescriptor, IEditorRegistry } from 'vs/workbench/browser/editor';
import { TerminalInputSerializer, TerminalEditor } from 'vs/workbench/contrib/terminal/browser/terminalEditor';
import { TerminalEditorInput } from 'vs/workbench/contrib/terminal/browser/terminalEditorInput';
import { terminalStrings } from 'vs/workbench/contrib/terminal/common/terminalStrings';
import { TerminalEditorService } from 'vs/workbench/contrib/terminal/browser/terminalEditorService';

// Register services
registerSingleton(ITerminalService, TerminalService, true);
registerSingleton(ITerminalEditorService, TerminalEditorService, true);
registerSingleton(IRemoteTerminalService, RemoteTerminalService);
registerSingleton(ITerminalInstanceService, TerminalInstanceService, true);

Expand All @@ -62,6 +69,18 @@ CommandsRegistry.registerCommand({ id: quickAccessNavigatePreviousInTerminalPick
registerTerminalPlatformConfiguration();
registerTerminalConfiguration();

Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories).registerEditorInputSerializer(TerminalEditorInput.ID, TerminalInputSerializer);
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
EditorDescriptor.create(
TerminalEditor,
TerminalEditor.ID,
terminalStrings.terminal
),
[
new SyncDescriptor(TerminalEditorInput)
]
);

// Register views
const VIEW_CONTAINER = Registry.as<IViewContainersRegistry>(ViewContainerExtensions.ViewContainersRegistry).registerViewContainer({
id: TERMINAL_VIEW_ID,
Expand Down
58 changes: 49 additions & 9 deletions src/vs/workbench/contrib/terminal/browser/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Orientation } from 'vs/base/browser/ui/splitview/splitview';
import { IEditableData } from 'vs/workbench/common/views';

export const ITerminalService = createDecorator<ITerminalService>('terminalService');
export const ITerminalEditorService = createDecorator<ITerminalEditorService>('terminalEditorService');
export const ITerminalInstanceService = createDecorator<ITerminalInstanceService>('terminalInstanceService');
export const IRemoteTerminalService = createDecorator<IRemoteTerminalService>('remoteTerminalService');

Expand Down Expand Up @@ -90,6 +91,29 @@ export const enum TerminalConnectionState {
Connected
}

export const enum TerminalTarget {
TerminalView = 'view',
Editor = 'editor'
}

export interface ICreateTerminalOptions {
/**
* The shell launch config or profile to launch with, when not specified the default terminal
* profile will be used.
*/
config?: IShellLaunchConfig | ITerminalProfile;
// TODO: Ensure this is supported for profiles
/**
* The current working directory to start with, this will override IShellLaunchConfig.cwd if
* specified.
*/
cwd?: string | URI;
/**
* Where to create the terminal, when not specified the default target will be used.
*/
target?: TerminalTarget;
}

export interface ITerminalService {
readonly _serviceBrand: undefined;

Expand Down Expand Up @@ -131,16 +155,10 @@ export interface ITerminalService {

/**
* Creates a terminal.
* @param shell The shell launch configuration to use.
*/
createTerminal(shell?: IShellLaunchConfig, cwd?: string | URI): ITerminalInstance;

/**
* Creates a terminal.
* @param profile The profile to launch the terminal with.
* @param options The options to create the terminal with, when not specified the default
* profile will be used at the default target.
*/
createTerminal(profile: ITerminalProfile): ITerminalInstance;

createTerminal(options?: ICreateTerminalOptions): ITerminalInstance;
createContributedTerminalProfile(extensionIdentifier: string, id: string, isSplitTerminal: boolean): Promise<void>;

/**
Expand All @@ -163,6 +181,7 @@ export interface ITerminalService {
*/
moveGroup(source: ITerminalInstance, target: ITerminalInstance): void;
moveInstance(source: ITerminalInstance, target: ITerminalInstance, side: 'before' | 'after'): void;
moveToEditor(source: ITerminalInstance): void;

/**
* Perform an action with the active terminal instance, if the terminal does
Expand Down Expand Up @@ -215,6 +234,20 @@ export interface ITerminalService {
setEditable(instance: ITerminalInstance, data: IEditableData | null): Promise<void>;
instanceIsSplit(instance: ITerminalInstance): boolean;
safeDisposeTerminal(instance: ITerminalInstance): Promise<void>;

getPlatformKey(): Promise<string>;
}

/**
* This service is responsible for integrating with the editor service and managing terminal
* editors.
*/
export interface ITerminalEditorService {
readonly _serviceBrand: undefined;

readonly terminalEditorInstances: ITerminalInstance[];

createEditor(instance: ITerminalInstance): Promise<void>;
}

export interface IRemoteTerminalService extends IOffProcessTerminalService {
Expand Down Expand Up @@ -295,6 +328,8 @@ export interface ITerminalInstance {
*/
processId: number | undefined;

target?: TerminalTarget;

/**
* The id of a persistent process. This is defined if this is a terminal created by a pty host
* that supports reconnection.
Expand Down Expand Up @@ -564,6 +599,11 @@ export interface ITerminalInstance {
*/
attachToElement(container: HTMLElement): Promise<void> | void;

/**
* Detaches the terminal instance from the terminal editor DOM element.
*/
detachFromElement(): void;

/**
* Configure the dimensions of the terminal instance.
*
Expand Down
47 changes: 41 additions & 6 deletions src/vs/workbench/contrib/terminal/browser/terminalActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Action } from 'vs/base/common/actions';
import { Codicon } from 'vs/base/common/codicons';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { Schemas } from 'vs/base/common/network';
import { isWindows, isLinux } from 'vs/base/common/platform';
import { isLinux, isWindows } from 'vs/base/common/platform';
import { withNullAsUndefined } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
Expand All @@ -30,9 +30,9 @@ import { ILocalTerminalService, ITerminalProfile, TerminalSettingId, TitleEventS
import { IWorkspaceContextService, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { PICK_WORKSPACE_FOLDER_COMMAND_ID } from 'vs/workbench/browser/actions/workspaceCommands';
import { FindInFilesCommand, IFindInFilesArgs } from 'vs/workbench/contrib/search/browser/searchActions';
import { Direction, IRemoteTerminalService, ITerminalInstance, ITerminalInstanceService, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
import { Direction, IRemoteTerminalService, ITerminalInstance, ITerminalInstanceService, ITerminalService, TerminalTarget } from 'vs/workbench/contrib/terminal/browser/terminal';
import { TerminalQuickAccessProvider } from 'vs/workbench/contrib/terminal/browser/terminalQuickAccess';
import { IRemoteTerminalAttachTarget, ITerminalConfigHelper, KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, KEYBINDING_CONTEXT_TERMINAL_ALT_BUFFER_ACTIVE, KEYBINDING_CONTEXT_TERMINAL_FIND_FOCUSED, KEYBINDING_CONTEXT_TERMINAL_FIND_NOT_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_FIND_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_IS_OPEN, KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED, KEYBINDING_CONTEXT_TERMINAL_TABS_FOCUS, KEYBINDING_CONTEXT_TERMINAL_TABS_SINGULAR_SELECTION, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, TERMINAL_ACTION_CATEGORY, TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
import { IRemoteTerminalAttachTarget, ITerminalConfigHelper, KEYBINDING_CONTEXT_TERMINAL_A11Y_TREE_FOCUS, KEYBINDING_CONTEXT_TERMINAL_ALT_BUFFER_ACTIVE, KEYBINDING_CONTEXT_TERMINAL_FIND_FOCUSED, KEYBINDING_CONTEXT_TERMINAL_FIND_NOT_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_FIND_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_IS_OPEN, KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED, KEYBINDING_CONTEXT_TERMINAL_TABS_FOCUS, KEYBINDING_CONTEXT_TERMINAL_TABS_SINGULAR_SELECTION, KEYBINDING_CONTEXT_TERMINAL_TEXT_SELECTED, TerminalCommandId, TERMINAL_ACTION_CATEGORY } from 'vs/workbench/contrib/terminal/common/terminal';
import { terminalStrings } from 'vs/workbench/contrib/terminal/common/terminalStrings';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
Expand Down Expand Up @@ -178,7 +178,7 @@ export function registerTerminalActions() {
}

if (profile) {
instance = terminalService.createTerminal(profile, cwd);
instance = terminalService.createTerminal({ config: profile, cwd });
} else {
instance = await terminalService.showProfileQuickPick('createInstance', cwd);
}
Expand All @@ -191,6 +191,39 @@ export function registerTerminalActions() {
}
});

registerAction2(class extends Action2 {
constructor() {
super({
id: TerminalCommandId.CreateTerminalEditor,
title: { value: localize('workbench.action.terminal.createTerminalEditor', "Create Terminal Editor"), original: 'Create Terminal Editor' },
f1: true,
category,
precondition: KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED
});
}
async run(accessor: ServicesAccessor) {
const terminalService = accessor.get(ITerminalService);
// TODO: Await openEditor
terminalService.createTerminal({
target: TerminalTarget.Editor
});
}
});

registerAction2(class extends Action2 {
constructor() {
super({
id: TerminalCommandId.MoveToEditor,
title: { value: localize('workbench.action.terminal.moveToEditor', "Move From Terminal View to Editor"), original: 'Move From Terminal View to Editor' },
f1: true,
category
});
}
async run(accessor: ServicesAccessor) {
const terminalService = accessor.get(ITerminalService);
terminalService.doWithActiveInstance(instance => terminalService.moveToEditor(instance));
}
});

registerAction2(class extends Action2 {
constructor() {
Expand Down Expand Up @@ -898,7 +931,9 @@ export function registerTerminalActions() {
}
const selected = await quickInputService.pick<IRemoteTerminalPick>(items, { canPickMany: false });
if (selected) {
const instance = terminalService.createTerminal({ attachPersistentProcess: selected.term });
const instance = terminalService.createTerminal({
config: { attachPersistentProcess: selected.term }
});
terminalService.setActiveInstance(instance);
terminalService.showPanel(true);
}
Expand Down Expand Up @@ -1779,7 +1814,7 @@ export function registerTerminalActions() {
if (quickSelectProfiles) {
const profile = quickSelectProfiles.find(profile => profile.profileName === profileSelection);
if (profile) {
const instance = terminalService.createTerminal(profile);
const instance = terminalService.createTerminal({ config: profile });
terminalService.setActiveInstance(instance);
} else {
console.warn(`No profile with name "${profileSelection}"`);
Expand Down
82 changes: 82 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalEditor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Dimension } from 'vs/base/browser/dom';
import { CancellationToken } from 'vs/base/common/cancellation';
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 { IThemeService } from 'vs/platform/theme/common/themeService';
import { EditorPane } from 'vs/workbench/browser/parts/editor/editorPane';
import { IEditorInputSerializer, IEditorOpenContext } from 'vs/workbench/common/editor';
import { TerminalEditorInput } from 'vs/workbench/contrib/terminal/browser/terminalEditorInput';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';

export class TerminalEditor extends EditorPane {

public static readonly ID = 'terminalEditor';

private _parentElement: HTMLElement | undefined;
private _editorInput?: TerminalEditorInput = undefined;

private _lastDimension?: Dimension;

override async setInput(newInput: TerminalEditorInput, options: IEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken) {
this._editorInput?.terminalInstance?.detachFromElement();
this._editorInput = newInput;
await super.setInput(newInput, options, context, token);
this._editorInput.terminalInstance.attachToElement(this._parentElement!);
if (this._lastDimension) {
this.layout(this._lastDimension);
}
this._editorInput.terminalInstance.setVisible(true);
}

// eslint-disable-next-line @typescript-eslint/naming-convention
protected createEditor(parent: HTMLElement): void {
this._parentElement = parent;
}

layout(dimension: Dimension): void {
if (this._editorInput?.terminalInstance) {
this._editorInput.terminalInstance.layout(dimension);
}
this._lastDimension = dimension;
}

override setVisible(visible: boolean, group?: IEditorGroup): void {
super.setVisible(visible, group);

if (!this._editorInput?.terminalInstance) {
return;
}

this._editorInput.terminalInstance.setVisible(visible);
}

constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IThemeService themeService: IThemeService,
@IStorageService storageService: IStorageService,
) {
super(TerminalEditor.ID, telemetryService, themeService, storageService);
}
}

export class TerminalInputSerializer implements IEditorInputSerializer {
public canSerialize(editorInput: TerminalEditorInput): boolean {
return false;
}

public serialize(editorInput: TerminalEditorInput): string | undefined {
return undefined;
}

public deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): TerminalEditorInput {
// TODO: Attach to instanceId via pty service
throw new Error('NYI');
}
}
Loading

0 comments on commit 22f216d

Please sign in to comment.