@@ -19,7 +19,7 @@ interface Variable {
1919 children ?: Variable [ ] ;
2020}
2121
22- interface DebuggerVariablesProps {
22+ interface DebuggerVariablesProps {
2323 apis : pxt . Map < pxtc . SymbolInfo > ;
2424 sequence : number ;
2525 breakpoint ?: pxsim . DebuggerBreakpointMessage ;
@@ -67,7 +67,7 @@ export class DebuggerVariables extends data.Component<DebuggerVariablesProps, De
6767 componentDidUpdate ( prevProps : DebuggerVariablesProps ) {
6868 if ( this . props . breakpoint ) {
6969 if ( this . props . sequence != this . state . renderedSequence ) {
70- this . updateVariables ( this . props . breakpoint . globals , this . props . breakpoint . stackframes , this . props . filters ) ;
70+ this . updateVariables ( this . props . breakpoint , this . props . filters ) ;
7171 }
7272 }
7373 else if ( ! this . state . frozen ) {
@@ -108,7 +108,7 @@ export class DebuggerVariables extends data.Component<DebuggerVariablesProps, De
108108 }
109109
110110 return < DebuggerTable header = { variableTableHeader } placeholderText = { placeholderText } >
111- { tableRows }
111+ { tableRows }
112112 </ DebuggerTable >
113113 }
114114
@@ -137,8 +137,12 @@ export class DebuggerVariables extends data.Component<DebuggerVariablesProps, De
137137 return result ;
138138 }
139139
140- updateVariables ( globals : pxsim . Variables , stackFrames : pxsim . StackFrameInfo [ ] , filters ?: string [ ] ) {
141- if ( ! globals ) {
140+ updateVariables (
141+ breakpoint : pxsim . DebuggerBreakpointMessage ,
142+ filters ?: string [ ]
143+ ) {
144+ const { globals, environmentGlobals, stackframes } = breakpoint ;
145+ if ( ! globals && ! environmentGlobals ) {
142146 // freeze the ui
143147 this . update ( true )
144148 return ;
@@ -150,14 +154,17 @@ export class DebuggerVariables extends data.Component<DebuggerVariablesProps, De
150154 if ( filters ) {
151155 updatedGlobals . variables = updatedGlobals . variables . filter ( v => filters . indexOf ( v . name ) !== - 1 )
152156 }
157+ // inject unfiltered environment variables
158+ if ( environmentGlobals )
159+ updatedGlobals . variables = updatedGlobals . variables . concat ( variablesToVariableList ( environmentGlobals ) ) ;
153160
154161 assignVarIds ( updatedGlobals . variables ) ;
155162
156163 let updatedFrames : ScopeVariables [ ] ;
157- if ( stackFrames ) {
164+ if ( stackframes ) {
158165 const oldFrames = this . state . stackFrames ;
159166
160- updatedFrames = stackFrames . map ( ( sf , index ) => {
167+ updatedFrames = stackframes . map ( ( sf , index ) => {
161168 const key = sf . breakpointId + "_" + index ;
162169
163170 for ( const frame of oldFrames ) {
@@ -219,7 +226,7 @@ export class DebuggerVariables extends data.Component<DebuggerVariablesProps, De
219226
220227 return result ;
221228
222- function collectVariables ( vars : Variable [ ] ) {
229+ function collectVariables ( vars : Variable [ ] ) {
223230 vars . forEach ( v => {
224231 result . push ( v ) ;
225232 if ( v . children ) {
@@ -261,8 +268,16 @@ export class DebuggerVariables extends data.Component<DebuggerVariablesProps, De
261268 }
262269}
263270
271+ function variablesToVariableList ( newVars : pxsim . Variables ) {
272+ const current = Object . keys ( newVars ) . map ( varName => ( {
273+ name : fixVarName ( varName ) ,
274+ value : newVars [ varName ]
275+ } ) ) ;
276+ return current ;
277+ }
278+
264279function updateScope ( lastScope : ScopeVariables , newVars : pxsim . Variables , params ?: Variable [ ] ) : ScopeVariables {
265- let current = Object . keys ( newVars ) . map ( varName => ( { name : fixVarName ( varName ) , value : newVars [ varName ] } ) ) ;
280+ let current = variablesToVariableList ( newVars ) ;
266281
267282 if ( params ) {
268283 current = params . concat ( current ) ;
0 commit comments