@@ -8,7 +8,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
88import * as dom from 'vs/base/browser/dom' ;
99import { CollapseAction } from 'vs/workbench/browser/viewlet' ;
1010import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet' ;
11- import { IDebugService , IExpression , IScope , CONTEXT_VARIABLES_FOCUSED , IStackFrame } from 'vs/workbench/contrib/debug/common/debug' ;
11+ import { IDebugService , IExpression , IScope , CONTEXT_VARIABLES_FOCUSED , IStackFrame , CONTEXT_DEBUG_PROTOCOL_VARIABLE_MENU_CONTEXT } from 'vs/workbench/contrib/debug/common/debug' ;
1212import { Variable , Scope , ErrorScope , StackFrame } from 'vs/workbench/contrib/debug/common/debugModel' ;
1313import { IContextMenuService } from 'vs/platform/contextview/browser/contextView' ;
1414import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
@@ -27,7 +27,7 @@ import { IAsyncDataTreeViewState } from 'vs/base/browser/ui/tree/asyncDataTree';
2727import { FuzzyScore , createMatches } from 'vs/base/common/filters' ;
2828import { HighlightedLabel , IHighlight } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel' ;
2929import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService' ;
30- import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
30+ import { IContextKeyService , IContextKey } from 'vs/platform/contextkey/common/contextkey' ;
3131import { dispose } from 'vs/base/common/lifecycle' ;
3232import { IViewDescriptorService } from 'vs/workbench/common/views' ;
3333import { IOpenerService } from 'vs/platform/opener/common/opener' ;
@@ -50,6 +50,7 @@ export class VariablesView extends ViewPane {
5050 private savedViewState = new Map < string , IAsyncDataTreeViewState > ( ) ;
5151 private autoExpandedScopes = new Set < string > ( ) ;
5252 private menu : IMenu ;
53+ private debugProtocolVariableMenuContext : IContextKey < string > ;
5354
5455 constructor (
5556 options : IViewletViewOptions ,
@@ -70,6 +71,7 @@ export class VariablesView extends ViewPane {
7071
7172 this . menu = menuService . createMenu ( MenuId . DebugVariablesContext , contextKeyService ) ;
7273 this . _register ( this . menu ) ;
74+ this . debugProtocolVariableMenuContext = CONTEXT_DEBUG_PROTOCOL_VARIABLE_MENU_CONTEXT . bindTo ( contextKeyService ) ;
7375
7476 // Use scheduler to prevent unnecessary flashing
7577 this . onFocusStackFrameScheduler = new RunOnceScheduler ( async ( ) => {
@@ -193,29 +195,27 @@ export class VariablesView extends ViewPane {
193195 const actions : IAction [ ] = [ ] ;
194196 const session = this . debugService . getViewModel ( ) . focusedSession ;
195197 if ( session && session . capabilities . supportsSetVariable ) {
196- actions . push ( new Action ( 'workbench.setValue' , nls . localize ( 'setValue' , "Set Value" ) , undefined , true , ( ) => {
198+ actions . push ( new Action ( 'workbench.setValue' , nls . localize ( 'setValue' , "Set Value" ) , undefined , true , async ( ) => {
197199 this . debugService . getViewModel ( ) . setSelectedExpression ( variable ) ;
198- return Promise . resolve ( ) ;
199200 } ) ) ;
200201 }
201202 actions . push ( this . instantiationService . createInstance ( CopyValueAction , CopyValueAction . ID , CopyValueAction . LABEL , variable , 'variables' ) ) ;
202203 if ( variable . evaluateName ) {
203- actions . push ( new Action ( 'debug.copyEvaluatePath' , nls . localize ( 'copyAsExpression' , "Copy as Expression" ) , undefined , true , ( ) => {
204- return this . clipboardService . writeText ( variable . evaluateName ! ) ;
204+ actions . push ( new Action ( 'debug.copyEvaluatePath' , nls . localize ( 'copyAsExpression' , "Copy as Expression" ) , undefined , true , async ( ) => {
205+ await this . clipboardService . writeText ( variable . evaluateName ! ) ;
205206 } ) ) ;
206207 actions . push ( new Separator ( ) ) ;
207- actions . push ( new Action ( 'debug.addToWatchExpressions' , nls . localize ( 'addToWatchExpressions' , "Add to Watch" ) , undefined , true , ( ) => {
208+ actions . push ( new Action ( 'debug.addToWatchExpressions' , nls . localize ( 'addToWatchExpressions' , "Add to Watch" ) , undefined , true , async ( ) => {
208209 this . debugService . addWatchExpression ( variable . evaluateName ) ;
209- return Promise . resolve ( undefined ) ;
210210 } ) ) ;
211211 }
212212 if ( session && session . capabilities . supportsDataBreakpoints ) {
213213 const response = await session . dataBreakpointInfo ( variable . name , variable . parent . reference ) ;
214214 const dataid = response ?. dataId ;
215215 if ( response && dataid ) {
216216 actions . push ( new Separator ( ) ) ;
217- actions . push ( new Action ( 'debug.breakWhenValueChanges' , nls . localize ( 'breakWhenValueChanges' , "Break When Value Changes" ) , undefined , true , ( ) => {
218- return this . debugService . addDataBreakpoint ( response . description , dataid , ! ! response . canPersist , response . accessTypes ) ;
217+ actions . push ( new Action ( 'debug.breakWhenValueChanges' , nls . localize ( 'breakWhenValueChanges' , "Break When Value Changes" ) , undefined , true , async ( ) => {
218+ await this . debugService . addDataBreakpoint ( response . description , dataid , ! ! response . canPersist , response . accessTypes ) ;
219219 } ) ) ;
220220 }
221221 }
@@ -225,6 +225,7 @@ export class VariablesView extends ViewPane {
225225 variable : variable . toDebugProtocolObject ( )
226226 } ;
227227 const actionsDisposable = createAndFillInContextMenuActions ( this . menu , { arg : context , shouldForwardArgs : false } , actions , this . contextMenuService ) ;
228+ this . debugProtocolVariableMenuContext . set ( variable . variableMenuContext || '' ) ;
228229
229230 this . contextMenuService . showContextMenu ( {
230231 getAnchor : ( ) => e . anchor ,
0 commit comments