Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix terminal editor bugs #127963

Merged
merged 9 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalEditorInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}));
Expand Down Expand Up @@ -138,12 +139,13 @@ export class TerminalEditorService extends Disposable implements ITerminalEditor

async openEditor(instance: ITerminalInstance): Promise<void> {
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 {
Expand Down