Skip to content

Commit

Permalink
Merge pull request #120591 from microsoft/merogge/tabs2
Browse files Browse the repository at this point in the history
terminal tabs UI
  • Loading branch information
Tyriar authored Apr 8, 2021
2 parents a4fed64 + 7a1e1fd commit 6062a54
Show file tree
Hide file tree
Showing 7 changed files with 547 additions and 201 deletions.
19 changes: 7 additions & 12 deletions src/vs/workbench/contrib/terminal/browser/terminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/term
import { TerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminalInstance';
import { TerminalTab } from 'vs/workbench/contrib/terminal/browser/terminalTab';
import { TerminalViewPane } from 'vs/workbench/contrib/terminal/browser/terminalView';
import { IAvailableProfilesRequest, IRemoteTerminalAttachTarget, ITerminalProfile, IStartExtensionTerminalRequest, ITerminalConfigHelper, ITerminalNativeWindowsDelegate, ITerminalProcessExtHostProxy, KEYBINDING_CONTEXT_TERMINAL_ALT_BUFFER_ACTIVE, KEYBINDING_CONTEXT_TERMINAL_FIND_VISIBLE, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_IS_OPEN, KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED, KEYBINDING_CONTEXT_TERMINAL_SHELL_TYPE, LinuxDistro, TERMINAL_VIEW_ID, ITerminalProfileObject, ITerminalExecutable, ITerminalProfileSource, ITerminalTypeContribution } from 'vs/workbench/contrib/terminal/common/terminal';
import { IAvailableProfilesRequest, IRemoteTerminalAttachTarget, ITerminalProfile, IStartExtensionTerminalRequest, ITerminalConfigHelper, ITerminalNativeWindowsDelegate, ITerminalProcessExtHostProxy, KEYBINDING_CONTEXT_TERMINAL_ALT_BUFFER_ACTIVE, KEYBINDING_CONTEXT_TERMINAL_FOCUS, KEYBINDING_CONTEXT_TERMINAL_IS_OPEN, KEYBINDING_CONTEXT_TERMINAL_PROCESS_SUPPORTED, KEYBINDING_CONTEXT_TERMINAL_SHELL_TYPE, LinuxDistro, TERMINAL_VIEW_ID, ITerminalProfileObject, ITerminalExecutable, ITerminalProfileSource, ITerminalTypeContribution } from 'vs/workbench/contrib/terminal/common/terminal';
import { escapeNonWindowsPath } from 'vs/workbench/contrib/terminal/common/terminalEnvironment';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
Expand All @@ -50,7 +50,6 @@ export class TerminalService implements ITerminalService {
private _terminalFocusContextKey: IContextKey<boolean>;
private _terminalShellTypeContextKey: IContextKey<string>;
private _terminalAltBufferActiveContextKey: IContextKey<boolean>;
private _findWidgetVisible: IContextKey<boolean>;
private _terminalTabs: ITerminalTab[] = [];
private _backgroundedTerminalInstances: ITerminalInstance[] = [];
private get _terminalInstances(): ITerminalInstance[] {
Expand Down Expand Up @@ -143,7 +142,6 @@ export class TerminalService implements ITerminalService {
this._terminalFocusContextKey = KEYBINDING_CONTEXT_TERMINAL_FOCUS.bindTo(this._contextKeyService);
this._terminalShellTypeContextKey = KEYBINDING_CONTEXT_TERMINAL_SHELL_TYPE.bindTo(this._contextKeyService);
this._terminalAltBufferActiveContextKey = KEYBINDING_CONTEXT_TERMINAL_ALT_BUFFER_ACTIVE.bindTo(this._contextKeyService);
this._findWidgetVisible = KEYBINDING_CONTEXT_TERMINAL_FIND_VISIBLE.bindTo(this._contextKeyService);
this._configHelper = this._instantiationService.createInstance(TerminalConfigHelper);
this.onTabDisposed(tab => this._removeTab(tab));
this.onActiveTabChanged(() => {
Expand Down Expand Up @@ -1041,32 +1039,29 @@ export class TerminalService implements ITerminalService {
public async focusFindWidget(): Promise<void> {
await this.showPanel(false);
const pane = this._viewsService.getActiveViewWithId(TERMINAL_VIEW_ID) as TerminalViewPane;
pane.focusFindWidget();
this._findWidgetVisible.set(true);
pane.terminalTabbedView.focusFindWidget();
}

public hideFindWidget(): void {
const pane = this._viewsService.getActiveViewWithId(TERMINAL_VIEW_ID) as TerminalViewPane;
if (pane) {
pane.hideFindWidget();
this._findWidgetVisible.reset();
pane.focus();
pane.terminalTabbedView.hideFindWidget();
}
}

public findNext(): void {
const pane = this._viewsService.getActiveViewWithId(TERMINAL_VIEW_ID) as TerminalViewPane;
if (pane) {
pane.showFindWidget();
pane.getFindWidget().find(false);
pane.terminalTabbedView.showFindWidget();
pane.terminalTabbedView.getFindWidget().find(false);
}
}

public findPrevious(): void {
const pane = this._viewsService.getActiveViewWithId(TERMINAL_VIEW_ID) as TerminalViewPane;
if (pane) {
pane.showFindWidget();
pane.getFindWidget().find(true);
pane.terminalTabbedView.showFindWidget();
pane.terminalTabbedView.getFindWidget().find(true);
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/vs/workbench/contrib/terminal/browser/terminalTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,11 @@ export class TerminalTab extends Disposable implements ITerminalTab {
}

// Fire events and dispose tab if it was the last instance
this._onInstancesChanged.fire();
if (this._terminalInstances.length === 0) {
this._onDisposed.fire(this);
this.dispose();
} else {
this._onInstancesChanged.fire();
}
}

Expand Down Expand Up @@ -403,6 +404,11 @@ export class TerminalTab extends Disposable implements ITerminalTab {
}

public get title(): string {
if (this._terminalInstances.length === 0) {
// Normally consumers should not call into title at all after the tab is disposed but
// this is required when the tab is used as part of a tree.
return '';
}
let title = this._titleWithConnectionStatus(this.terminalInstances[0]);
for (let i = 1; i < this.terminalInstances.length; i++) {
const instance = this.terminalInstances[i];
Expand Down
Loading

0 comments on commit 6062a54

Please sign in to comment.