File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,8 @@ export namespace Debugger {
363
363
return mappedExpression ;
364
364
}
365
365
366
+ const metatableAccessor : LuaDebug . MetatableAccessor = "lldbg_getmetatable" ;
367
+
366
368
function execute (
367
369
statement : string ,
368
370
level : number ,
@@ -384,12 +386,14 @@ export namespace Debugger {
384
386
{ } ,
385
387
{
386
388
__index ( this : unknown , name : string ) {
389
+ if ( name === metatableAccessor ) {
390
+ return getmetatable ;
391
+ }
387
392
const variable = locs . vars [ name ] ?? ups . vars [ name ] ;
388
393
if ( variable !== undefined ) {
389
394
return variable . val ;
390
- } else {
391
- return fenv [ name ] ;
392
395
}
396
+ return fenv [ name ] ;
393
397
} ,
394
398
__newindex ( this : unknown , name : string , val : unknown ) {
395
399
const variable = locs . vars [ name ] ?? ups . vars [ name ] ;
Original file line number Diff line number Diff line change @@ -111,6 +111,8 @@ declare namespace LuaDebug {
111
111
type StartToken = "@lldbg|" ;
112
112
type EndToken = "|lldbg@" ;
113
113
114
+ type MetatableAccessor = "lldbg_getmetatable" ;
115
+
114
116
type ScriptRootsEnv = "LOCAL_LUA_DEBUGGER_SCRIPT_ROOTS" ;
115
117
type BreakInCoroutinesEnv = "LOCAL_LUA_DEBUGGER_BREAK_IN_COROUTINES" ;
116
118
type StepUnmappedLinesEnv = "LOCAL_LUA_DEBUGGER_STEP_UNMAPPED_LINES" ;
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ const enum OutputCategory {
68
68
const maxStackCount = 100 ;
69
69
const metatableDisplayName = "[[metatable]]" ;
70
70
const tableLengthDisplayName = "[[length]]" ;
71
+ const metatableAccessor : LuaDebug . MetatableAccessor = "lldbg_getmetatable" ;
71
72
const envVariable = "LOCAL_LUA_DEBUGGER_VSCODE" ;
72
73
const filePathEnvVariable = "LOCAL_LUA_DEBUGGER_FILEPATH" ;
73
74
const scriptRootsEnvVariable : LuaDebug . ScriptRootsEnv = "LOCAL_LUA_DEBUGGER_SCRIPT_ROOTS" ;
@@ -520,7 +521,9 @@ export class LuaDebugSession extends LoggingDebugSession {
520
521
}
521
522
522
523
if ( typeof vars . metatable !== "undefined" && typeof baseName !== "undefined" ) {
523
- variables . push ( this . buildVariable ( vars . metatable , `getmetatable(${ baseName } )` , metatableDisplayName ) ) ;
524
+ variables . push (
525
+ this . buildVariable ( vars . metatable , `${ metatableAccessor } (${ baseName } )` , metatableDisplayName )
526
+ ) ;
524
527
}
525
528
526
529
if ( typeof vars . length !== "undefined" && ! isMultiResult ) {
You can’t perform that action at this time.
0 commit comments