From d4c12779e8e4f6b940737bb83472a66ef873e1e3 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Sun, 4 Jul 2021 11:03:12 -0700 Subject: [PATCH 1/7] fix #126469 --- src/vs/workbench/contrib/terminal/browser/terminalEditor.ts | 5 +++++ .../contrib/terminal/browser/terminalEditorService.ts | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) 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/terminalEditorService.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts index 3d1734127902f..a2d1e74b844ea 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts @@ -14,7 +14,7 @@ import { ITerminalEditorService, ITerminalInstance, ITerminalInstanceService } f 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; @@ -141,8 +141,7 @@ export class TerminalEditorService extends Disposable implements ITerminalEditor await this._editorService.openEditor(input, { pinned: true, forceReload: true - }, - SIDE_GROUP + } ); } From f8063d744ad2142b21fdaede04e51810334f7fde Mon Sep 17 00:00:00 2001 From: meganrogge Date: Sun, 4 Jul 2021 11:25:14 -0700 Subject: [PATCH 2/7] fix #127901 --- .../workbench/contrib/terminal/browser/terminalQuickAccess.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalQuickAccess.ts b/src/vs/workbench/contrib/terminal/browser/terminalQuickAccess.ts index 8da864acb1fbf..6f262d01a8c24 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalQuickAccess.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalQuickAccess.ts @@ -121,7 +121,7 @@ export class TerminalQuickAccessProvider extends PickerQuickAccessProvider { if (terminal.target === TerminalLocation.Editor) { - this._terminalEditorService.openEditor(terminal); + terminal.focus(); this._terminalEditorService.setActiveInstance(terminal); } else { this._terminalGroupService.showPanel(!event.inBackground); From 836163c83f73f69be6eb4edbe2dc4b4ff2e4369a Mon Sep 17 00:00:00 2001 From: meganrogge Date: Sun, 4 Jul 2021 11:35:10 -0700 Subject: [PATCH 3/7] open or focus editor --- .../workbench/contrib/terminal/browser/terminal.ts | 1 + .../terminal/browser/terminalEditorService.ts | 14 ++++++++++++++ .../terminal/browser/terminalQuickAccess.ts | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminal.ts b/src/vs/workbench/contrib/terminal/browser/terminal.ts index 74892f6d7f13f..3362712691ff6 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminal.ts @@ -197,6 +197,7 @@ export interface ITerminalEditorService extends ITerminalInstanceHost, ITerminal readonly instances: readonly ITerminalInstance[]; openEditor(instance: ITerminalInstance): Promise; + openOrFocusEditor(instance: ITerminalInstance): Promise; getOrCreateEditorInput(instance: ITerminalInstance | SerializedTerminalEditorInput): TerminalEditorInput; detachActiveEditorInstance(): ITerminalInstance; detachInstance(instance: ITerminalInstance): void; diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts index a2d1e74b844ea..6b3b2ab9cb41b 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts @@ -145,6 +145,20 @@ export class TerminalEditorService extends Disposable implements ITerminalEditor ); } + async openOrFocusEditor(instance: ITerminalInstance): Promise { + const input = this.getOrCreateEditorInput(instance); + console.log(this._editorService.activeEditorPane?.group); + if (!this._editorService.activeEditorPane?.group.contains(input)) { + instance.focus(); + return; + } + await this._editorService.openEditor(input, { + pinned: true, + forceReload: true + } + ); + } + getOrCreateEditorInput(instance: ITerminalInstance | SerializedTerminalEditorInput, isFutureSplit: boolean = false): TerminalEditorInput { let cachedEditor; if ('id' in instance) { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalQuickAccess.ts b/src/vs/workbench/contrib/terminal/browser/terminalQuickAccess.ts index 6f262d01a8c24..24a4854a972f5 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalQuickAccess.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalQuickAccess.ts @@ -121,7 +121,7 @@ export class TerminalQuickAccessProvider extends PickerQuickAccessProvider { if (terminal.target === TerminalLocation.Editor) { - terminal.focus(); + this._terminalEditorService.openOrFocusEditor(terminal); this._terminalEditorService.setActiveInstance(terminal); } else { this._terminalGroupService.showPanel(!event.inBackground); From 6a554360c5849aa10a6521e46ccdd84789ba6461 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Sun, 4 Jul 2021 11:37:31 -0700 Subject: [PATCH 4/7] remove log --- .../workbench/contrib/terminal/browser/terminalEditorService.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts index 6b3b2ab9cb41b..ce5d6d7a4f0ef 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts @@ -147,7 +147,6 @@ export class TerminalEditorService extends Disposable implements ITerminalEditor async openOrFocusEditor(instance: ITerminalInstance): Promise { const input = this.getOrCreateEditorInput(instance); - console.log(this._editorService.activeEditorPane?.group); if (!this._editorService.activeEditorPane?.group.contains(input)) { instance.focus(); return; From c55f4e2ba090d81ab163a980e372bae798509083 Mon Sep 17 00:00:00 2001 From: meganrogge Date: Mon, 5 Jul 2021 13:28:05 -0700 Subject: [PATCH 5/7] fix #127968 --- .../terminal/browser/terminalEditorInput.ts | 11 +++++++++++ .../terminal/browser/terminalEditorService.ts | 15 +++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) 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 ce5d6d7a4f0ef..582f8d1768449 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts @@ -9,7 +9,7 @@ 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'; @@ -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,23 +139,21 @@ 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 } ); + input.setGroup(editorPane?.group); } async openOrFocusEditor(instance: ITerminalInstance): Promise { const input = this.getOrCreateEditorInput(instance); - if (!this._editorService.activeEditorPane?.group.contains(input)) { - instance.focus(); - return; - } await this._editorService.openEditor(input, { pinned: true, forceReload: true - } + }, + input.group ); } From 38898828c6917ad7ca1bd63efb75848acb22239b Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Mon, 5 Jul 2021 20:53:48 +0000 Subject: [PATCH 6/7] clean up --- .../workbench/contrib/terminal/browser/terminal.ts | 1 - .../terminal/browser/terminalEditorService.ts | 13 ++----------- .../contrib/terminal/browser/terminalQuickAccess.ts | 2 +- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminal.ts b/src/vs/workbench/contrib/terminal/browser/terminal.ts index 3362712691ff6..74892f6d7f13f 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminal.ts @@ -197,7 +197,6 @@ export interface ITerminalEditorService extends ITerminalInstanceHost, ITerminal readonly instances: readonly ITerminalInstance[]; openEditor(instance: ITerminalInstance): Promise; - openOrFocusEditor(instance: ITerminalInstance): Promise; getOrCreateEditorInput(instance: ITerminalInstance | SerializedTerminalEditorInput): TerminalEditorInput; detachActiveEditorInstance(): ITerminalInstance; detachInstance(instance: ITerminalInstance): void; diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts index 582f8d1768449..9e66218b66847 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts @@ -142,19 +142,10 @@ export class TerminalEditorService extends Disposable implements ITerminalEditor const editorPane: IEditorPane | undefined = await this._editorService.openEditor(input, { pinned: true, forceReload: true - } - ); - input.setGroup(editorPane?.group); - } - - async openOrFocusEditor(instance: ITerminalInstance): Promise { - const input = this.getOrCreateEditorInput(instance); - await this._editorService.openEditor(input, { - pinned: true, - forceReload: true }, - input.group + input.group ); + input.setGroup(editorPane?.group); } getOrCreateEditorInput(instance: ITerminalInstance | SerializedTerminalEditorInput, isFutureSplit: boolean = false): TerminalEditorInput { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalQuickAccess.ts b/src/vs/workbench/contrib/terminal/browser/terminalQuickAccess.ts index 24a4854a972f5..8da864acb1fbf 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalQuickAccess.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalQuickAccess.ts @@ -121,7 +121,7 @@ export class TerminalQuickAccessProvider extends PickerQuickAccessProvider { if (terminal.target === TerminalLocation.Editor) { - this._terminalEditorService.openOrFocusEditor(terminal); + this._terminalEditorService.openEditor(terminal); this._terminalEditorService.setActiveInstance(terminal); } else { this._terminalGroupService.showPanel(!event.inBackground); From 263e59a05ce2e8dcff4f45de52e4b4a9656a77d2 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Mon, 5 Jul 2021 21:01:35 +0000 Subject: [PATCH 7/7] format document --- .../workbench/contrib/terminal/browser/terminalEditorService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts index 9e66218b66847..1ec4c4c59dffe 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts @@ -143,7 +143,7 @@ export class TerminalEditorService extends Disposable implements ITerminalEditor pinned: true, forceReload: true }, - input.group + input.group ); input.setGroup(editorPane?.group); }