@@ -6,7 +6,7 @@ import { instrumentOperationAsVsCodeCommand } from "vscode-extension-telemetry-w
6
6
7
7
export function registerVariableMenuCommands ( context : vscode . ExtensionContext ) : void {
8
8
vscode . workspace . onDidChangeConfiguration ( ( event ) => {
9
- if ( event . affectsConfiguration ( "java.debug.settings" ) ) {
9
+ if ( event . affectsConfiguration ( "java.debug.settings" ) || event . affectsConfiguration ( "debug.autoExpandLazyVariables" ) ) {
10
10
updateContextKeys ( ) ;
11
11
}
12
12
} ) ;
@@ -33,9 +33,20 @@ export function registerVariableMenuCommands(context: vscode.ExtensionContext):
33
33
"java.debug.variables.showToString" , ( ) => updateVariableFormatter ( "showToString" , true ) ) ) ;
34
34
context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
35
35
"java.debug.variables.notShowToString" , ( ) => updateVariableFormatter ( "showToString" , false ) ) ) ;
36
+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
37
+ "java.debug.variables.autoExpandLazyVariables" , ( ) => toggleLazyVariableSetting ( true ) ) ) ;
38
+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand (
39
+ "java.debug.variables.manualExpandLazyVariables" , ( ) => toggleLazyVariableSetting ( false ) ) ) ;
36
40
}
37
41
38
- function updateVariableFormatter ( key : string , value : any ) {
42
+ async function updateVariableFormatter ( key : string , value : any ) {
43
+ const debugSettingsRoot : vscode . WorkspaceConfiguration = vscode . workspace . getConfiguration ( "java.debug.settings" ) ;
44
+ // Update the formatter to settings.json
45
+ await debugSettingsRoot . update ( key , value , getConfigurationTarget ( "java.debug" , "settings" ) ) ;
46
+ refreshVariableView ( ) ;
47
+ }
48
+
49
+ function refreshVariableView ( ) {
39
50
const debugSettingsRoot : vscode . WorkspaceConfiguration = vscode . workspace . getConfiguration ( "java.debug.settings" ) ;
40
51
if ( vscode . debug . activeDebugSession && vscode . debug . activeDebugSession . type === "java" ) {
41
52
const formatter : any = {
@@ -45,19 +56,30 @@ function updateVariableFormatter(key: string, value: any) {
45
56
showLogicalStructure : debugSettingsRoot . showLogicalStructure ,
46
57
showToString : debugSettingsRoot . showToString ,
47
58
} ;
48
- formatter [ key ] = value ;
49
59
vscode . debug . activeDebugSession . customRequest ( "refreshVariables" , formatter ) ;
50
60
}
61
+ }
62
+
63
+ async function toggleLazyVariableSetting ( toggle : boolean ) {
64
+ const javadDebugSettingsRoot : vscode . WorkspaceConfiguration = vscode . workspace . getConfiguration ( "java.debug.settings" ) ;
65
+ if ( ! javadDebugSettingsRoot . showToString ) {
66
+ await javadDebugSettingsRoot . update ( "showToString" , true , getConfigurationTarget ( "java.debug" , "settings" ) ) ;
67
+ }
51
68
52
- // Update the formatter to settings.json
53
- const inspect = vscode . workspace . getConfiguration ( "java.debug" ) . inspect ( "settings" ) ;
54
- let configurationTarget = vscode . ConfigurationTarget . Global ;
69
+ const debugSettingsRoot : vscode . WorkspaceConfiguration = vscode . workspace . getConfiguration ( "debug" ) ;
70
+ await debugSettingsRoot . update ( "autoExpandLazyVariables" , toggle , getConfigurationTarget ( "debug" , "autoExpandLazyVariables" ) ) ;
71
+ refreshVariableView ( ) ;
72
+ }
73
+
74
+ function getConfigurationTarget ( section : string , key : string ) : vscode . ConfigurationTarget {
75
+ const inspect = vscode . workspace . getConfiguration ( section ) . inspect ( key ) ;
55
76
if ( inspect && inspect . workspaceFolderValue !== undefined ) {
56
- configurationTarget = vscode . ConfigurationTarget . WorkspaceFolder ;
77
+ return vscode . ConfigurationTarget . WorkspaceFolder ;
57
78
} else if ( inspect && inspect . workspaceValue !== undefined ) {
58
- configurationTarget = vscode . ConfigurationTarget . Workspace ;
79
+ return vscode . ConfigurationTarget . Workspace ;
80
+ } else {
81
+ return vscode . ConfigurationTarget . Global ;
59
82
}
60
- debugSettingsRoot . update ( key , value , configurationTarget ) ;
61
83
}
62
84
63
85
function updateContextKeys ( ) {
@@ -69,4 +91,9 @@ function updateContextKeys() {
69
91
vscode . commands . executeCommand ( "setContext" , "javadebug:showStaticVariables" , debugSettingsRoot . showStaticVariables ? "on" : "off" ) ;
70
92
vscode . commands . executeCommand ( "setContext" , "javadebug:showToString" , debugSettingsRoot . showToString ? "on" : "off" ) ;
71
93
}
94
+
95
+ const globalDebugRoot : vscode . WorkspaceConfiguration = vscode . workspace . getConfiguration ( "debug" ) ;
96
+ if ( globalDebugRoot ) {
97
+ vscode . commands . executeCommand ( "setContext" , "javadebug:expandLazyVariable" , globalDebugRoot . autoExpandLazyVariables ? "on" : "off" ) ;
98
+ }
72
99
}
0 commit comments