@@ -126,7 +126,7 @@ export class VariablesView extends ViewPane {
126126 new ScopesRenderer ( ) ,
127127 new ScopeErrorRenderer ( ) ,
128128 ] ,
129- new VariablesDataSource ( this . debugService ) , {
129+ this . instantiationService . createInstance ( VariablesDataSource ) , {
130130 accessibilityProvider : new VariablesAccessibilityProvider ( ) ,
131131 identityProvider : { getId : ( element : IExpression | IScope ) => element . getId ( ) } ,
132132 keyboardNavigationLabelProvider : { getKeyboardNavigationLabel : ( e : IExpression | IScope ) => e . name } ,
@@ -171,7 +171,7 @@ export class VariablesView extends ViewPane {
171171 let horizontalScrolling : boolean | undefined ;
172172 this . _register ( this . debugService . getViewModel ( ) . onDidSelectExpression ( e => {
173173 const variable = e ?. expression ;
174- if ( variable instanceof Variable && ! e ?. settingWatch ) {
174+ if ( variable && this . tree . hasNode ( variable ) ) {
175175 horizontalScrolling = this . tree . options . horizontalScrolling ;
176176 if ( horizontalScrolling ) {
177177 this . tree . updateOptions ( { horizontalScrolling : false } ) ;
@@ -210,12 +210,24 @@ export class VariablesView extends ViewPane {
210210 }
211211
212212 private onMouseDblClick ( e : ITreeMouseEvent < IExpression | IScope > ) : void {
213- const session = this . debugService . getViewModel ( ) . focusedSession ;
214- if ( session && e . element instanceof Variable && session . capabilities . supportsSetVariable && ! e . element . presentationHint ?. attributes ?. includes ( 'readOnly' ) && ! e . element . presentationHint ?. lazy ) {
213+ if ( this . canSetExpressionValue ( e . element ) ) {
215214 this . debugService . getViewModel ( ) . setSelectedExpression ( e . element , false ) ;
216215 }
217216 }
218217
218+ private canSetExpressionValue ( e : IExpression | IScope | null ) : e is IExpression {
219+ const session = this . debugService . getViewModel ( ) . focusedSession ;
220+ if ( ! session ) {
221+ return false ;
222+ }
223+
224+ if ( e instanceof VisualizedExpression ) {
225+ return ! ! e . treeItem . canEdit ;
226+ }
227+
228+ return e instanceof Variable && ! e . presentationHint ?. attributes ?. includes ( 'readOnly' ) && ! e . presentationHint ?. lazy ;
229+ }
230+
219231 private async onContextMenu ( e : ITreeContextMenuEvent < IExpression | IScope > ) : Promise < void > {
220232 const variable = e . element ;
221233 if ( ! ( variable instanceof Variable ) || ! variable . value ) {
@@ -415,7 +427,7 @@ export class VisualizedVariableRenderer extends AbstractExpressionsRenderer {
415427 */
416428 public static rendererOnVisualizationRange ( model : IViewModel , tree : AsyncDataTree < any , any , any > ) : IDisposable {
417429 return model . onDidChangeVisualization ( ( { original } ) => {
418- if ( ! tree . hasElement ( original ) ) {
430+ if ( ! tree . hasNode ( original ) ) {
419431 return ;
420432 }
421433
@@ -461,24 +473,21 @@ export class VisualizedVariableRenderer extends AbstractExpressionsRenderer {
461473 }
462474
463475 protected override getInputBoxOptions ( expression : IExpression ) : IInputBoxOptions | undefined {
464- const variable = < Variable > expression ;
476+ const viz = < VisualizedExpression > expression ;
465477 return {
466478 initialValue : expression . value ,
467479 ariaLabel : localize ( 'variableValueAriaLabel' , "Type new variable value" ) ,
468480 validationOptions : {
469- validation : ( ) => variable . errorMessage ? ( { content : variable . errorMessage } ) : null
481+ validation : ( ) => viz . errorMessage ? ( { content : viz . errorMessage } ) : null
470482 } ,
471483 onFinish : ( value : string , success : boolean ) => {
472- variable . errorMessage = undefined ;
473- const focusedStackFrame = this . debugService . getViewModel ( ) . focusedStackFrame ;
474- if ( success && variable . value !== value && focusedStackFrame ) {
475- variable . setVariable ( value , focusedStackFrame )
476- // Need to force watch expressions and variables to update since a variable change can have an effect on both
477- . then ( ( ) => {
478- // Do not refresh scopes due to a node limitation #15520
479- forgetScopes = false ;
480- this . debugService . getViewModel ( ) . updateViews ( ) ;
481- } ) ;
484+ viz . errorMessage = undefined ;
485+ if ( success ) {
486+ viz . edit ( value ) . then ( ( ) => {
487+ // Do not refresh scopes due to a node limitation #15520
488+ forgetScopes = false ;
489+ this . debugService . getViewModel ( ) . updateViews ( ) ;
490+ } ) ;
482491 }
483492 }
484493 } ;
@@ -494,7 +503,10 @@ export class VisualizedVariableRenderer extends AbstractExpressionsRenderer {
494503 createAndFillInContextMenuActions ( menu , { arg : context , shouldForwardArgs : false } , { primary, secondary : [ ] } , 'inline' ) ;
495504
496505 if ( viz . original ) {
497- primary . push ( new Action ( 'debugViz' , localize ( 'removeVisualizer' , 'Remove Visualizer' ) , ThemeIcon . asClassName ( Codicon . close ) , undefined , ( ) => this . debugService . getViewModel ( ) . setVisualizedExpression ( viz . original ! , undefined ) ) ) ;
506+ const action = new Action ( 'debugViz' , localize ( 'removeVisualizer' , 'Remove Visualizer' ) , ThemeIcon . asClassName ( Codicon . eye ) , true , ( ) => this . debugService . getViewModel ( ) . setVisualizedExpression ( viz . original ! , undefined ) ) ;
507+ action . checked = true ;
508+ primary . push ( action ) ;
509+ actionBar . domNode . style . display = 'initial' ;
498510 }
499511 actionBar . clear ( ) ;
500512 actionBar . context = context ;
@@ -601,7 +613,7 @@ export class VariablesRenderer extends AbstractExpressionsRenderer {
601613 if ( resolved . type === DebugVisualizationType . Command ) {
602614 viz . execute ( ) ;
603615 } else {
604- const replacement = await this . visualization . setVisualizedNodeFor ( resolved . id , expression ) ;
616+ const replacement = await this . visualization . getVisualizedNodeFor ( resolved . id , expression ) ;
605617 if ( replacement ) {
606618 this . debugService . getViewModel ( ) . setVisualizedExpression ( expression , replacement ) ;
607619 }
0 commit comments