diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditor.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditor.ts index 568c1908128f7..7a6f85bd325e0 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditor.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditor.ts @@ -101,6 +101,11 @@ export class TerminalEditor extends EditorPane { } } + override clearInput(): void { + super.clearInput(); + this._editorInput = undefined; + } + private _setActiveInstance(): void { if (!this._editorInput?.terminalInstance) { return; diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts index 760e5eedaaa19..1d268e5bfd73e 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts @@ -13,6 +13,7 @@ import { TerminalEditor } from 'vs/workbench/contrib/terminal/browser/terminalEd import { getColorClass, getUriClasses } from 'vs/workbench/contrib/terminal/browser/terminalIcon'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { TerminalLocation } from 'vs/platform/terminal/common/terminal'; +import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService'; export class TerminalEditorInput extends EditorInput { @@ -21,6 +22,16 @@ export class TerminalEditorInput extends EditorInput { private _isDetached = false; private _copyInstance?: ITerminalInstance; + private _group: IEditorGroup | undefined; + + setGroup(group: IEditorGroup | undefined) { + this._group = group; + } + + get group(): IEditorGroup | undefined { + return this._group; + } + override get typeId(): string { return TerminalEditorInput.ID; } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts index 3d1734127902f..1ec4c4c59dffe 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts @@ -9,12 +9,12 @@ import { FindReplaceState } from 'vs/editor/contrib/find/findState'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IShellLaunchConfig, TerminalLocation } from 'vs/platform/terminal/common/terminal'; -import { IEditorInput } from 'vs/workbench/common/editor'; +import { IEditorInput, IEditorPane } from 'vs/workbench/common/editor'; import { ITerminalEditorService, ITerminalInstance, ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal'; import { TerminalEditor } from 'vs/workbench/contrib/terminal/browser/terminalEditor'; import { TerminalEditorInput } from 'vs/workbench/contrib/terminal/browser/terminalEditorInput'; import { SerializedTerminalEditorInput } from 'vs/workbench/contrib/terminal/browser/terminalEditorSerializer'; -import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService'; +import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; export class TerminalEditorService extends Disposable implements ITerminalEditorService { declare _serviceBrand: undefined; @@ -49,7 +49,8 @@ export class TerminalEditorService extends Disposable implements ITerminalEditor this._register(this._editorService.onDidActiveEditorChange(() => { const activeEditor = this._editorService.activeEditor; const instance = activeEditor instanceof TerminalEditorInput ? activeEditor?.terminalInstance : undefined; - if (instance) { + if (instance && activeEditor instanceof TerminalEditorInput) { + activeEditor?.setGroup(this._editorService.activeEditorPane?.group); this._setActiveInstance(instance); } })); @@ -138,12 +139,13 @@ export class TerminalEditorService extends Disposable implements ITerminalEditor async openEditor(instance: ITerminalInstance): Promise { const input = this.getOrCreateEditorInput(instance); - await this._editorService.openEditor(input, { + const editorPane: IEditorPane | undefined = await this._editorService.openEditor(input, { pinned: true, forceReload: true }, - SIDE_GROUP + input.group ); + input.setGroup(editorPane?.group); } getOrCreateEditorInput(instance: ITerminalInstance | SerializedTerminalEditorInput, isFutureSplit: boolean = false): TerminalEditorInput {