Skip to content

Commit

Permalink
fix #121655
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Apr 21, 2021
1 parent 27cf6a3 commit e815d28
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/vs/workbench/contrib/terminal/browser/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export interface ITerminalService {
onDidRegisterProcessSupport: Event<void>;
onDidChangeConnectionState: Event<void>;
onProfilesConfigChanged: Event<void>;
onPanelMovedToSide: Event<void>;

/**
* Creates a terminal.
Expand Down
3 changes: 3 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export class TerminalService implements ITerminalService {
public get connectionState(): TerminalConnectionState { return this._connectionState; }
private readonly _onProfilesConfigChanged = new Emitter<void>();
public get onProfilesConfigChanged(): Event<void> { return this._onProfilesConfigChanged.event; }
private readonly _onPanelMovedToSide = new Emitter<void>();
public get onPanelMovedToSide(): Event<void> { return this._onPanelMovedToSide.event; }
private readonly _localTerminalService?: ILocalTerminalService;

constructor(
Expand Down Expand Up @@ -974,6 +976,7 @@ export class TerminalService implements ITerminalService {

const terminalTab = this._instantiationService.createInstance(TerminalTab, this._terminalContainer, shellLaunchConfig);
this._terminalTabs.push(terminalTab);
terminalTab.onPanelMovedToSide(() => this._onPanelMovedToSide.fire());

const instance = terminalTab.terminalInstances[0];

Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/terminalTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ export class TerminalTab extends Disposable implements ITerminalTab {
public readonly onDisposed: Event<ITerminalTab> = this._onDisposed.event;
private readonly _onInstancesChanged: Emitter<void> = this._register(new Emitter<void>());
public readonly onInstancesChanged: Event<void> = this._onInstancesChanged.event;
private readonly _onPanelMovedToSide = new Emitter<void>();
public get onPanelMovedToSide(): Event<void> { return this._onPanelMovedToSide.event; }
constructor(
private _container: HTMLElement | undefined,
shellLaunchConfigOrInstance: IShellLaunchConfig | ITerminalInstance | undefined,
Expand Down Expand Up @@ -465,6 +467,9 @@ export class TerminalTab extends Disposable implements ITerminalTab {
this.resizePanes(this._initialRelativeSizes);
this._initialRelativeSizes = undefined;
}
if (terminalPositionChanged && this._splitPaneContainer.orientation === Orientation.VERTICAL) {
this._onPanelMovedToSide.fire();
}
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/terminalTabbedView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ export class TerminalTabbedView extends Disposable {
this._splitView = new SplitView(parentElement, { orientation: Orientation.HORIZONTAL, proportionalLayout: false });

this._setupSplitView();

this._terminalService.onPanelMovedToSide(() => {
try {
this._updateWidgetWidth(MIN_TABS_WIDGET_WIDTH);
} catch (e) {

This comment has been minimized.

Copy link
@Tyriar

Tyriar Apr 21, 2021

Member

nit: Does this throw for something we need to worry about? If not this would be preferred:

} catch {
  // Ignore
}
}
});
}

private _getLastWidgetWidth(): number {
Expand Down Expand Up @@ -203,7 +210,7 @@ export class TerminalTabbedView extends Disposable {
}

private _updateWidgetWidth(width: number): void {
if (width < MIDPOINT_WIDGET_WIDTH && width > MIN_TABS_WIDGET_WIDTH) {
if (width < MIDPOINT_WIDGET_WIDTH && width >= MIN_TABS_WIDGET_WIDTH) {
width = MIN_TABS_WIDGET_WIDTH;
this._splitView.resizeView(this._tabTreeIndex, width);
} else if (width >= MIDPOINT_WIDGET_WIDTH && width < DEFAULT_TABS_WIDGET_WIDTH) {
Expand Down Expand Up @@ -293,7 +300,8 @@ export class TerminalTabbedView extends Disposable {
}

private _refreshHasTextClass() {
this._tabTreeContainer.classList.toggle('has-text', this._tabTreeContainer.clientWidth >= MIDPOINT_WIDGET_WIDTH);
this._tabTreeContainer.classList.toggle('has-text', this._tabTreeContainer.clientWidth > MIDPOINT_WIDGET_WIDTH);
console.log('has text', this._tabTreeContainer.classList.contains('has-text'));

This comment has been minimized.

Copy link
@Tyriar

Tyriar Apr 21, 2021

Member

Left in log

}

private _updateTheme(theme?: IColorTheme): void {
Expand Down

0 comments on commit e815d28

Please sign in to comment.