Merge pull request #236696 from microsoft/tyriar/236517
Polish terminal toggle creation and add hideOnLastClosed settingpull/236708/head
commit
1b43b074a2
|
@ -103,6 +103,7 @@ export const enum TerminalSettingId {
|
|||
EnablePersistentSessions = 'terminal.integrated.enablePersistentSessions',
|
||||
PersistentSessionReviveProcess = 'terminal.integrated.persistentSessionReviveProcess',
|
||||
HideOnStartup = 'terminal.integrated.hideOnStartup',
|
||||
HideOnLastClosed = 'terminal.integrated.hideOnLastClosed',
|
||||
CustomGlyphs = 'terminal.integrated.customGlyphs',
|
||||
RescaleOverlappingGlyphs = 'terminal.integrated.rescaleOverlappingGlyphs',
|
||||
PersistentSessionScrollback = 'terminal.integrated.persistentSessionScrollback',
|
||||
|
|
|
@ -83,7 +83,7 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
|
|||
hidePanel(): void {
|
||||
// Hide the panel if the terminal is in the panel and it has no sibling views
|
||||
const panel = this._viewDescriptorService.getViewContainerByViewId(TERMINAL_VIEW_ID);
|
||||
if (panel && this._viewDescriptorService.getViewContainerModel(panel).activeViewDescriptors.length === 1) {
|
||||
if (panel && this._viewDescriptorService.getViewContainerModel(panel).visibleViewDescriptors.length === 1) {
|
||||
this._viewsService.closeView(TERMINAL_VIEW_ID);
|
||||
TerminalContextKeys.tabsMouse.bindTo(this._contextKeyService).set(false);
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ export class TerminalService extends Disposable implements ITerminalService {
|
|||
// down. When shutting down the panel is locked in place so that it is restored upon next
|
||||
// launch.
|
||||
this._register(this._terminalGroupService.onDidChangeActiveInstance(instance => {
|
||||
if (!instance && !this._isShuttingDown) {
|
||||
if (!instance && !this._isShuttingDown && this._terminalConfigService.config.hideOnLastClosed) {
|
||||
this._terminalGroupService.hidePanel();
|
||||
}
|
||||
if (instance?.shellType) {
|
||||
|
|
|
@ -57,6 +57,11 @@ export class TerminalViewPane extends ViewPane {
|
|||
private _terminalTabbedView?: TerminalTabbedView;
|
||||
get terminalTabbedView(): TerminalTabbedView | undefined { return this._terminalTabbedView; }
|
||||
private _isInitialized: boolean = false;
|
||||
/**
|
||||
* Tracks an active promise of terminal creation requested by this component. This helps prevent
|
||||
* double creation for example when toggling a terminal's visibility and focusing it.
|
||||
*/
|
||||
private _isTerminalBeingCreated: boolean = false;
|
||||
private readonly _newDropdown: MutableDisposable<DropdownWithPrimaryActionViewItem> = this._register(new MutableDisposable());
|
||||
private readonly _dropdownMenu: IMenu;
|
||||
private readonly _singleTabMenu: IMenu;
|
||||
|
@ -164,7 +169,8 @@ export class TerminalViewPane extends ViewPane {
|
|||
if (!wasInitialized) {
|
||||
switch (hideOnStartup) {
|
||||
case 'never':
|
||||
this._terminalService.createTerminal({ location: TerminalLocation.Panel });
|
||||
this._isTerminalBeingCreated = true;
|
||||
this._terminalService.createTerminal({ location: TerminalLocation.Panel }).finally(() => this._isTerminalBeingCreated = false);
|
||||
break;
|
||||
case 'whenEmpty':
|
||||
if (this._terminalService.restoredGroupCount === 0) {
|
||||
|
@ -175,7 +181,10 @@ export class TerminalViewPane extends ViewPane {
|
|||
return;
|
||||
}
|
||||
|
||||
this._terminalService.createTerminal({ location: TerminalLocation.Panel });
|
||||
if (!this._isTerminalBeingCreated) {
|
||||
this._isTerminalBeingCreated = true;
|
||||
this._terminalService.createTerminal({ location: TerminalLocation.Panel }).finally(() => this._isTerminalBeingCreated = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,6 +329,10 @@ export class TerminalViewPane extends ViewPane {
|
|||
override focus() {
|
||||
super.focus();
|
||||
if (this._terminalService.connectionState === TerminalConnectionState.Connected) {
|
||||
if (this._terminalGroupService.instances.length === 0 && !this._isTerminalBeingCreated) {
|
||||
this._isTerminalBeingCreated = true;
|
||||
this._terminalService.createTerminal({ location: TerminalLocation.Panel }).finally(() => this._isTerminalBeingCreated = false);
|
||||
}
|
||||
this._terminalGroupService.showPanel(true);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -211,6 +211,7 @@ export interface ITerminalConfiguration {
|
|||
experimental?: {
|
||||
windowsUseConptyDll?: boolean;
|
||||
};
|
||||
hideOnLastClosed: boolean;
|
||||
}
|
||||
|
||||
export interface ITerminalFont {
|
||||
|
|
|
@ -549,6 +549,11 @@ const terminalConfiguration: IConfigurationNode = {
|
|||
],
|
||||
default: 'never'
|
||||
},
|
||||
[TerminalSettingId.HideOnLastClosed]: {
|
||||
description: localize('terminal.integrated.hideOnLastClosed', "Whether to hide the terminal view when the last terminal is closed. This will only happen when the terminal is the only visible view in the view container."),
|
||||
type: 'boolean',
|
||||
default: true
|
||||
},
|
||||
[TerminalSettingId.CustomGlyphs]: {
|
||||
markdownDescription: localize('terminal.integrated.customGlyphs', "Whether to draw custom glyphs for block element and box drawing characters instead of using the font, which typically yields better rendering with continuous lines. Note that this doesn't work when {0} is disabled.", `\`#${TerminalSettingId.GpuAcceleration}#\``),
|
||||
type: 'boolean',
|
||||
|
|
Loading…
Reference in New Issue