@@ -14,9 +14,11 @@ import { config } from "../config";
1414import { ServiceExtensionArgs , timeDilationNormal , timeDilationSlow , VmServiceExtensions } from "../flutter/vm_service_extensions" ;
1515import { PubGlobal } from "../pub/global" ;
1616import { DevToolsManager } from "../sdk/dev_tools/manager" ;
17+ import { isValidEntryFile } from "../utils" ;
1718import { DartDebugSessionInformation , ProgressMessage } from "../utils/vscode/debug" ;
1819
1920export const debugSessions : DartDebugSessionInformation [ ] = [ ] ;
21+ const CURRENT_FILE_RUNNABLE = "dart-code:currentFileIsRunnable" ;
2022
2123// Workaround for https://github.com/microsoft/vscode/issues/100115
2224const dynamicDebugSessionName = "Dart " ;
@@ -64,6 +66,7 @@ export class DebugCommands {
6466 context . subscriptions . push ( vs . debug . onDidStartDebugSession ( ( s ) => this . handleDebugSessionStart ( s ) ) ) ;
6567 context . subscriptions . push ( vs . debug . onDidReceiveDebugSessionCustomEvent ( ( e ) => this . handleDebugSessionCustomEvent ( e ) ) ) ;
6668 context . subscriptions . push ( vs . debug . onDidTerminateDebugSession ( ( s ) => this . handleDebugSessionEnd ( s ) ) ) ;
69+ context . subscriptions . push ( vs . window . onDidChangeActiveTextEditor ( ( e ) => this . updateEditorContexts ( e ) ) ) ;
6770
6871 context . subscriptions . push ( vs . commands . registerCommand ( "flutter.togglePlatform" , ( ) => this . vmServices . toggle ( VmServiceExtension . PlatformOverride , "iOS" , "android" ) ) ) ;
6972 context . subscriptions . push ( vs . commands . registerCommand ( "flutter.toggleDebugPainting" , ( ) => this . vmServices . toggle ( VmServiceExtension . DebugPaint ) ) ) ;
@@ -571,4 +574,9 @@ export class DebugCommands {
571574 session . session . customRequest ( "serviceExtension" , args ) ;
572575 } ) ;
573576 }
577+
578+ private updateEditorContexts ( e : vs . TextEditor | undefined ) : void {
579+ const isRunnable = ! ! ( e && e . document && e . document . uri . scheme === "file" && isValidEntryFile ( fsPath ( e . document . uri ) ) ) ;
580+ vs . commands . executeCommand ( "setContext" , CURRENT_FILE_RUNNABLE , isRunnable ) ;
581+ }
574582}
0 commit comments