@@ -21,14 +21,17 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
2121import { WorkbenchStateContext } from 'vs/workbench/browser/contextkeys' ;
2222import { OpenFolderAction , OpenFileAction , OpenFileFolderAction } from 'vs/workbench/browser/actions/workspaceActions' ;
2323import { isMacintosh } from 'vs/base/common/platform' ;
24+ import { isCodeEditor } from 'vs/editor/browser/editorBrowser' ;
2425
25- const CONTEXT_DEBUGGER_INTERESTED = new RawContextKey < boolean > ( 'debuggerInterested' , false ) ;
26+ const CONTEXT_DEBUG_START_LANGUAGE = new RawContextKey < string > ( 'debugStartLanguage' , undefined ) ;
27+ const CONTEXT_DEBUGGER_INTERESTED_IN_ACTIVE_EDITOR = new RawContextKey < boolean > ( 'debuggerInterestedInActiveEditor' , false ) ;
2628
2729export class StartView extends ViewPane {
2830
2931 static ID = 'workbench.debug.startView' ;
3032 static LABEL = localize ( 'start' , "Start" ) ;
3133
34+ private debugStartLanguageContext : IContextKey < string > ;
3235 private debuggerInterestedContext : IContextKey < boolean > ;
3336
3437 constructor (
@@ -46,11 +49,20 @@ export class StartView extends ViewPane {
4649 ) {
4750 super ( { ...( options as IViewPaneOptions ) , ariaHeaderLabel : localize ( 'debugStart' , "Debug Start Section" ) } , keybindingService , contextMenuService , configurationService , contextKeyService , viewDescriptorService , instantiationService , openerService , themeService ) ;
4851
49- this . debuggerInterestedContext = CONTEXT_DEBUGGER_INTERESTED . bindTo ( contextKeyService ) ;
52+ this . debugStartLanguageContext = CONTEXT_DEBUG_START_LANGUAGE . bindTo ( contextKeyService ) ;
53+ this . debuggerInterestedContext = CONTEXT_DEBUGGER_INTERESTED_IN_ACTIVE_EDITOR . bindTo ( contextKeyService ) ;
5054 const setContextKey = ( ) => {
51- const activeEditor = this . editorService . activeTextEditorWidget ;
52- const debuggerLabels = this . debugService . getConfigurationManager ( ) . getDebuggerLabelsForEditor ( activeEditor ) ;
53- this . debuggerInterestedContext . set ( debuggerLabels . length > 0 ) ;
55+ const editor = this . editorService . activeTextEditorWidget ;
56+ if ( isCodeEditor ( editor ) ) {
57+ const model = editor . getModel ( ) ;
58+ const language = model ? model . getLanguageIdentifier ( ) . language : undefined ;
59+ if ( language && this . debugService . getConfigurationManager ( ) . isDebuggerInterestedInLanguage ( language ) ) {
60+ this . debugStartLanguageContext . set ( language ) ;
61+ this . debuggerInterestedContext . set ( true ) ;
62+ return ;
63+ }
64+ }
65+ this . debuggerInterestedContext . set ( false ) ;
5466 } ;
5567 this . _register ( editorService . onDidActiveEditorChange ( setContextKey ) ) ;
5668 this . _register ( this . debugService . getConfigurationManager ( ) . onDidRegisterDebugger ( setContextKey ) ) ;
@@ -64,7 +76,7 @@ export class StartView extends ViewPane {
6476const viewsRegistry = Registry . as < IViewsRegistry > ( Extensions . ViewsRegistry ) ;
6577viewsRegistry . registerViewWelcomeContent ( StartView . ID , {
6678 content : localize ( 'openAFileWhichCanBeDebugged' , "[Open a file](command:{0}) which can be debugged or run." , isMacintosh ? OpenFileFolderAction . ID : OpenFileAction . ID ) ,
67- when : CONTEXT_DEBUGGER_INTERESTED . toNegated ( )
79+ when : CONTEXT_DEBUGGER_INTERESTED_IN_ACTIVE_EDITOR
6880} ) ;
6981
7082viewsRegistry . registerViewWelcomeContent ( StartView . ID , {
0 commit comments