@@ -30,6 +30,7 @@ export interface LabeledUint8Array extends Uint8Array {
3030export class MemoryProvider {
3131 public static ReadKey = `${ manifest . PACKAGE_NAME } .canRead` ;
3232 public static WriteKey = `${ manifest . PACKAGE_NAME } .canWrite` ;
33+ public static ReadVariableKey = `${ manifest . PACKAGE_NAME } .canReadVariable` ;
3334
3435 private _onDidStopDebug = new vscode . EventEmitter < vscode . DebugSession > ( ) ;
3536 public readonly onDidStopDebug = this . _onDidStopDebug . event ;
@@ -105,17 +106,20 @@ export class MemoryProvider {
105106 createContext ( session = vscode . debug . activeDebugSession ) : SessionContext {
106107 const sessionId = session ?. id ;
107108 const capabilities = sessionId ? this . sessionDebugCapabilities . get ( sessionId ) : undefined ;
109+ const canReadVariable = this . supportShowVariables ( ) ;
108110 return {
109111 sessionId,
110112 canRead : ! ! capabilities ?. supportsReadMemoryRequest ,
111- canWrite : ! ! capabilities ?. supportsWriteMemoryRequest
113+ canWrite : ! ! capabilities ?. supportsWriteMemoryRequest ,
114+ canReadVariable : ! ! capabilities ?. supportsReadMemoryRequest && ! ! canReadVariable
112115 } ;
113116 }
114117
115118 protected setContext ( session ?: vscode . DebugSession ) : void {
116119 const newContext = this . createContext ( session ) ;
117120 vscode . commands . executeCommand ( 'setContext' , MemoryProvider . ReadKey , newContext . canRead ) ;
118121 vscode . commands . executeCommand ( 'setContext' , MemoryProvider . WriteKey , newContext . canWrite ) ;
122+ vscode . commands . executeCommand ( 'setContext' , MemoryProvider . ReadVariableKey , newContext . canReadVariable ) ;
119123 this . _onDidChangeSessionContext . fire ( newContext ) ;
120124 }
121125
@@ -206,4 +210,10 @@ export class MemoryProvider {
206210 const handler = this . adapterRegistry ?. getHandlerForSession ( session . type ) ;
207211 return handler ?. getCurrentContext ?.( session ) ;
208212 }
213+
214+ public supportShowVariables ( ) : boolean {
215+ const session = this . assertActiveSession ( 'supports show variables' ) ;
216+ const handler = this . adapterRegistry ?. getHandlerForSession ( session . type ) ;
217+ return handler ?. supportShowVariables ?.( session ) ?? true ;
218+ }
209219}
0 commit comments