diff --git a/src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts b/src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts index 405b81daeed1e2d43b10aaa33ff5f417ffd8765b..29dcf72e75209641a4a27ec799e13e97cff6bb28 100644 --- a/src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts +++ b/src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts @@ -11,7 +11,6 @@ import * as objects from 'vs/base/common/objects'; import { URI as uri } from 'vs/base/common/uri'; import * as resources from 'vs/base/common/resources'; import { IJSONSchema } from 'vs/base/common/jsonSchema'; -import * as editorCommon from 'vs/editor/common/editorCommon'; import { ITextModel } from 'vs/editor/common/model'; import { IEditor } from 'vs/workbench/common/editor'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; @@ -434,15 +433,8 @@ export class ConfigurationManager implements IConfigurationManager { return this.debuggers.filter(dbg => strings.equalsIgnoreCase(dbg.type, type)).pop(); } - getDebuggerLabelsForEditor(editor: editorCommon.IEditor | undefined): string[] { - if (isCodeEditor(editor)) { - const model = editor.getModel(); - const language = model ? model.getLanguageIdentifier().language : undefined; - - return this.debuggers.filter(a => language && a.languages && a.languages.indexOf(language) >= 0).map(d => d.label); - } - - return []; + isDebuggerInterestedInLanguage(language: string): boolean { + return this.debuggers.filter(a => language && a.languages && a.languages.indexOf(language) >= 0).length > 0; } async guessDebugger(type?: string): Promise { diff --git a/src/vs/workbench/contrib/debug/browser/startView.ts b/src/vs/workbench/contrib/debug/browser/startView.ts index 89a25705c9483235ade182bd7a4030f4e80792af..3362a4a32b9e956e00a2c4dc9dc34b5f0baa24ed 100644 --- a/src/vs/workbench/contrib/debug/browser/startView.ts +++ b/src/vs/workbench/contrib/debug/browser/startView.ts @@ -21,14 +21,17 @@ import { IOpenerService } from 'vs/platform/opener/common/opener'; import { WorkbenchStateContext } from 'vs/workbench/browser/contextkeys'; import { OpenFolderAction, OpenFileAction, OpenFileFolderAction } from 'vs/workbench/browser/actions/workspaceActions'; import { isMacintosh } from 'vs/base/common/platform'; +import { isCodeEditor } from 'vs/editor/browser/editorBrowser'; -const CONTEXT_DEBUGGER_INTERESTED = new RawContextKey('debuggerInterested', false); +const CONTEXT_DEBUG_START_LANGUAGE = new RawContextKey('debugStartLanguage', undefined); +const CONTEXT_DEBUGGER_INTERESTED_IN_ACTIVE_EDITOR = new RawContextKey('debuggerInterestedInActiveEditor', false); export class StartView extends ViewPane { static ID = 'workbench.debug.startView'; static LABEL = localize('start', "Start"); + private debugStartLanguageContext: IContextKey; private debuggerInterestedContext: IContextKey; constructor( @@ -46,11 +49,20 @@ export class StartView extends ViewPane { ) { super({ ...(options as IViewPaneOptions), ariaHeaderLabel: localize('debugStart', "Debug Start Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService); - this.debuggerInterestedContext = CONTEXT_DEBUGGER_INTERESTED.bindTo(contextKeyService); + this.debugStartLanguageContext = CONTEXT_DEBUG_START_LANGUAGE.bindTo(contextKeyService); + this.debuggerInterestedContext = CONTEXT_DEBUGGER_INTERESTED_IN_ACTIVE_EDITOR.bindTo(contextKeyService); const setContextKey = () => { - const activeEditor = this.editorService.activeTextEditorWidget; - const debuggerLabels = this.debugService.getConfigurationManager().getDebuggerLabelsForEditor(activeEditor); - this.debuggerInterestedContext.set(debuggerLabels.length > 0); + const editor = this.editorService.activeTextEditorWidget; + if (isCodeEditor(editor)) { + const model = editor.getModel(); + const language = model ? model.getLanguageIdentifier().language : undefined; + if (language && this.debugService.getConfigurationManager().isDebuggerInterestedInLanguage(language)) { + this.debugStartLanguageContext.set(language); + this.debuggerInterestedContext.set(true); + return; + } + } + this.debuggerInterestedContext.set(false); }; this._register(editorService.onDidActiveEditorChange(setContextKey)); this._register(this.debugService.getConfigurationManager().onDidRegisterDebugger(setContextKey)); @@ -64,7 +76,7 @@ export class StartView extends ViewPane { const viewsRegistry = Registry.as(Extensions.ViewsRegistry); viewsRegistry.registerViewWelcomeContent(StartView.ID, { content: localize('openAFileWhichCanBeDebugged', "[Open a file](command:{0}) which can be debugged or run.", isMacintosh ? OpenFileFolderAction.ID : OpenFileAction.ID), - when: CONTEXT_DEBUGGER_INTERESTED.toNegated() + when: CONTEXT_DEBUGGER_INTERESTED_IN_ACTIVE_EDITOR }); viewsRegistry.registerViewWelcomeContent(StartView.ID, { diff --git a/src/vs/workbench/contrib/debug/common/debug.ts b/src/vs/workbench/contrib/debug/common/debug.ts index 9a9fbceb7bf24244d9e4aff5349cc72505757fdf..d753ab2f888f68f6aa83804e6d83819e6a2dfd20 100644 --- a/src/vs/workbench/contrib/debug/common/debug.ts +++ b/src/vs/workbench/contrib/debug/common/debug.ts @@ -647,7 +647,7 @@ export interface IConfigurationManager { activateDebuggers(activationEvent: string, debugType?: string): Promise; - getDebuggerLabelsForEditor(editor: editorCommon.IEditor | undefined): string[]; + isDebuggerInterestedInLanguage(language: string): boolean; hasDebugConfigurationProvider(debugType: string): boolean; registerDebugConfigurationProvider(debugConfigurationProvider: IDebugConfigurationProvider): IDisposable;