diff --git a/src/vs/workbench/parts/debug/browser/debugStatus.ts b/src/vs/workbench/parts/debug/browser/debugStatus.ts index 4ed7c675b9068..6e2ef96a9d9eb 100644 --- a/src/vs/workbench/parts/debug/browser/debugStatus.ts +++ b/src/vs/workbench/parts/debug/browser/debugStatus.ts @@ -10,22 +10,25 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar'; -import { IDebugService, State } from 'vs/workbench/parts/debug/common/debug'; +import { IDebugService, State, IDebugConfiguration } from 'vs/workbench/parts/debug/common/debug'; import { Themable, STATUS_BAR_FOREGROUND } from 'vs/workbench/common/theme'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; const $ = dom.$; export class DebugStatus extends Themable implements IStatusbarItem { private toDispose: IDisposable[]; private container: HTMLElement; + private statusBarItem: HTMLElement; private label: HTMLElement; private icon: HTMLElement; - private hidden = true; + private showInStatusBar: string; constructor( @IQuickOpenService private quickOpenService: IQuickOpenService, @IDebugService private debugService: IDebugService, - @IThemeService themeService: IThemeService + @IThemeService themeService: IThemeService, + @IConfigurationService configurationService: IConfigurationService ) { super(themeService); this.toDispose = []; @@ -33,9 +36,24 @@ export class DebugStatus extends Themable implements IStatusbarItem { this.setLabel(); })); this.toDispose.push(this.debugService.onDidChangeState(state => { - if (state !== State.Inactive && this.hidden) { - this.hidden = false; - this.render(this.container); + if (state !== State.Inactive && this.showInStatusBar === 'onFirstSessionStart') { + this.doRender(); + } + })); + this.showInStatusBar = configurationService.getValue('debug').showInStatusBar; + this.toDispose.push(configurationService.onDidChangeConfiguration(e => { + if (e.affectsConfiguration('debug.showInStatusBar')) { + this.showInStatusBar = configurationService.getValue('debug').showInStatusBar; + if (this.showInStatusBar === 'never' && this.statusBarItem) { + this.statusBarItem.hidden = true; + } else { + if (this.statusBarItem) { + this.statusBarItem.hidden = false; + } + if (this.showInStatusBar === 'always') { + this.doRender(); + } + } } })); } @@ -49,24 +67,30 @@ export class DebugStatus extends Themable implements IStatusbarItem { public render(container: HTMLElement): IDisposable { this.container = container; - if (!this.hidden) { - const statusBarItem = dom.append(container, $('.debug-statusbar-item')); - this.toDispose.push(dom.addDisposableListener(statusBarItem, 'click', () => { + if (this.showInStatusBar === 'always') { + this.doRender(); + } + // noop, we render when we decide is best + return this; + } + + private doRender(): void { + if (!this.statusBarItem && this.container) { + this.statusBarItem = dom.append(this.container, $('.debug-statusbar-item')); + this.toDispose.push(dom.addDisposableListener(this.statusBarItem, 'click', () => { this.quickOpenService.show('debug ').done(undefined, errors.onUnexpectedError); })); - statusBarItem.title = nls.localize('selectAndStartDebug', "Select and start debug configuration"); - const a = dom.append(statusBarItem, $('a')); + this.statusBarItem.title = nls.localize('selectAndStartDebug', "Select and start debug configuration"); + const a = dom.append(this.statusBarItem, $('a')); this.icon = dom.append(a, $('.icon')); this.label = dom.append(a, $('span.label')); this.setLabel(); this.updateStyles(); } - - return this; } private setLabel(): void { - if (this.label && !this.hidden) { + if (this.label && this.statusBarItem) { const manager = this.debugService.getConfigurationManager(); const name = manager.selectedName || ''; this.label.textContent = manager.getLaunches().length > 1 ? `${name} (${manager.selectedLaunch.workspace.name})` : name; diff --git a/src/vs/workbench/parts/debug/browser/media/debug.contribution.css b/src/vs/workbench/parts/debug/browser/media/debug.contribution.css index 05d23a6ffd0df..c0f23e9662f96 100644 --- a/src/vs/workbench/parts/debug/browser/media/debug.contribution.css +++ b/src/vs/workbench/parts/debug/browser/media/debug.contribution.css @@ -109,9 +109,13 @@ padding: 0 5px 0 5px; } +.monaco-workbench .part.statusbar .debug-statusbar-item.hidden { + display: none; +} + .monaco-workbench .part.statusbar .debug-statusbar-item .icon { -webkit-mask: url('continue.svg') no-repeat 50% 50%; - -webkit-mask-size: 18px; + -webkit-mask-size: 16px; display: inline-block; padding-right: 2px; width: 16px; diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index b6c74071cb4ff..9e08b4ff90bc8 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -323,6 +323,7 @@ export interface IDebugConfiguration { openExplorerOnEnd: boolean; inlineValues: boolean; hideActionBar: boolean; + showInStatusBar: string; internalConsoleOptions: string; } diff --git a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts index 2203a758fa5d3..fbce85bb5508c 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts @@ -188,6 +188,11 @@ configurationRegistry.registerConfiguration({ description: nls.localize({ comment: ['This is the description for a setting'], key: 'hideActionBar' }, "Controls if the floating debug action bar should be hidden"), default: false }, + 'debug.showInStatusBar': { + enum: ['never', 'always', 'onFirstSessionStart'], + description: nls.localize({ comment: ['This is the description for a setting'], key: 'showInStatusBar' }, "Controls when the debug status bar should be visible"), + default: 'onFirstSessionStart' + }, 'debug.internalConsoleOptions': INTERNAL_CONSOLE_OPTIONS_SCHEMA, 'debug.openDebug': { enum: ['neverOpen', 'openOnSessionStart', 'openOnFirstSessionStart'],