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

Minimum size for new split terminals #59140

Merged
merged 2 commits into from
Sep 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/vs/workbench/parts/terminal/browser/terminalTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { SplitView, Orientation, IView, Sizing } from 'vs/base/browser/ui/splitv
import { IPartService, Position } from 'vs/workbench/services/part/common/partService';

const SPLIT_PANE_MIN_SIZE = 120;
const TERMINAL_MIN_USEFUL_SIZE = 250;

class SplitPaneContainer {
private _height: number;
Expand Down Expand Up @@ -361,6 +362,10 @@ export class TerminalTab extends Disposable implements ITerminalTab {
configHelper: ITerminalConfigHelper,
shellLaunchConfig: IShellLaunchConfig
): ITerminalInstance {
const newTerminalSize = ((this._panelPosition === Position.BOTTOM ? this._container.clientWidth : this._container.clientHeight) / (this._terminalInstances.length + 1));
if (newTerminalSize < TERMINAL_MIN_USEFUL_SIZE) {
return undefined;
}
const instance = this._terminalService.createInstance(
terminalFocusContextKey,
configHelper,
Expand Down
11 changes: 8 additions & 3 deletions src/vs/workbench/parts/terminal/common/terminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export abstract class TerminalService implements ITerminalService {
}

protected abstract _showTerminalCloseConfirmation(): TPromise<boolean>;
protected abstract _showNotEnoughSpaceToast(): void;
public abstract createTerminal(shell?: IShellLaunchConfig, wasNewTerminalAction?: boolean): ITerminalInstance;
public abstract createTerminalRenderer(name: string): ITerminalInstance;
public abstract createInstance(terminalFocusContextKey: IContextKey<boolean>, configHelper: ITerminalConfigHelper, container: HTMLElement, shellLaunchConfig: IShellLaunchConfig, doCreateProcess: boolean): ITerminalInstance;
Expand Down Expand Up @@ -263,10 +264,14 @@ export abstract class TerminalService implements ITerminalService {
}

const instance = tab.split(this._terminalFocusContextKey, this.configHelper, shellLaunchConfig);
this._initInstanceListeners(instance);
this._onInstancesChanged.fire();
if (instance) {
this._initInstanceListeners(instance);
this._onInstancesChanged.fire();

this._terminalTabs.forEach((t, i) => t.setVisible(i === this._activeTabIndex));
this._terminalTabs.forEach((t, i) => t.setVisible(i === this._activeTabIndex));
} else {
this._showNotEnoughSpaceToast();
}
}

protected _initInstanceListeners(instance: ITerminalInstance): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export class TerminalService extends AbstractTerminalService implements ITermina

this._terminalTabs = [];
this._configHelper = this._instantiationService.createInstance(TerminalConfigHelper);

ipc.on('vscode:openFiles', (_event: any, request: IOpenFileRequest) => {
// if the request to open files is coming in from the integrated terminal (identified though
// the termProgram variable) and we are instructed to wait for editors close, wait for the
Expand Down Expand Up @@ -287,6 +286,10 @@ export class TerminalService extends AbstractTerminalService implements ITermina
}).then(res => !res.confirmed);
}

protected _showNotEnoughSpaceToast(): void {
this._notificationService.warn(nls.localize('terminal.minWidth', "Not enough space to split terminal."));
}

public setContainers(panelContainer: HTMLElement, terminalContainer: HTMLElement): void {
this._configHelper.panelContainer = panelContainer;
this._terminalContainer = terminalContainer;
Expand Down