3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
+ import { createServer , Server } from 'net' ;
6
7
import * as vscode from 'vscode' ;
7
8
import * as nls from 'vscode-nls' ;
8
- import { createServer , Server } from 'net' ;
9
9
10
10
const localize = nls . loadMessageBundle ( ) ;
11
11
const ON_TEXT = localize ( 'status.text.auto.attach.on' , 'Auto Attach: On' ) ;
@@ -15,10 +15,12 @@ const TOGGLE_COMMAND = 'extension.node-debug.toggleAutoAttach';
15
15
const JS_DEBUG_SETTINGS = 'debug.javascript' ;
16
16
const JS_DEBUG_USEPREVIEWAA = 'usePreviewAutoAttach' ;
17
17
const JS_DEBUG_IPC_KEY = 'jsDebugIpcState' ;
18
+ const JS_DEBUG_REFRESH_SETTINGS = [ 'autoAttachSmartPattern' , 'autoAttachFilter' ] ; // settings that, when changed, should cause us to refresh js-debug vars
18
19
const NODE_DEBUG_SETTINGS = 'debug.node' ;
19
20
const AUTO_ATTACH_SETTING = 'autoAttach' ;
20
21
const LAST_STATE_STORAGE_KEY = 'lastState' ;
21
22
23
+
22
24
type AUTO_ATTACH_VALUES = 'disabled' | 'on' | 'off' ;
23
25
24
26
const enum State {
@@ -45,10 +47,23 @@ export function activate(context: vscode.ExtensionContext): void {
45
47
`${ JS_DEBUG_SETTINGS } .${ JS_DEBUG_USEPREVIEWAA } ` ,
46
48
] ;
47
49
50
+ const refreshConfigurationSettings = JS_DEBUG_REFRESH_SETTINGS . map ( s => `${ JS_DEBUG_SETTINGS } .${ s } ` ) ;
51
+
48
52
context . subscriptions . push (
49
53
vscode . workspace . onDidChangeConfiguration ( ( e ) => {
50
54
if ( effectualConfigurationSettings . some ( setting => e . affectsConfiguration ( setting ) ) ) {
51
55
updateAutoAttach ( ) ;
56
+ } else if ( refreshConfigurationSettings . some ( setting => e . affectsConfiguration ( setting ) ) ) {
57
+ currentState = currentState . then ( async s => {
58
+ if ( s . state !== State . OnWithJsDebug ) {
59
+ return s ;
60
+ }
61
+
62
+ await transitions [ State . OnWithJsDebug ] . exit ?.( context , s . transitionData ) ;
63
+ await clearJsDebugAttachState ( context ) ;
64
+ const transitionData = await transitions [ State . OnWithJsDebug ] . enter ?.( context ) ;
65
+ return { context, state : State . OnWithJsDebug , transitionData } ;
66
+ } ) ;
52
67
}
53
68
} )
54
69
) ;
@@ -138,6 +153,7 @@ async function clearJsDebugAttachState(context: vscode.ExtensionContext) {
138
153
interface CachedIpcState {
139
154
ipcAddress : string ;
140
155
jsDebugPath : string ;
156
+ settingsValue : string ;
141
157
}
142
158
143
159
interface StateTransition < StateData > {
@@ -278,18 +294,34 @@ async function getIpcAddress(context: vscode.ExtensionContext) {
278
294
const jsDebugPath = vscode . extensions . getExtension ( 'ms-vscode.js-debug-nightly' ) ?. extensionPath
279
295
|| vscode . extensions . getExtension ( 'ms-vscode.js-debug' ) ?. extensionPath ;
280
296
281
- if ( cachedIpc && cachedIpc . jsDebugPath === jsDebugPath ) {
297
+ const settingsValue = getJsDebugSettingKey ( ) ;
298
+ if ( cachedIpc && cachedIpc . jsDebugPath === jsDebugPath && cachedIpc . settingsValue === settingsValue ) {
282
299
return cachedIpc . ipcAddress ;
283
300
}
284
301
285
302
const result = await vscode . commands . executeCommand < { ipcAddress : string ; } > (
286
- 'extension.js-debug.setAutoAttachVariables'
303
+ 'extension.js-debug.setAutoAttachVariables' ,
304
+ cachedIpc ?. ipcAddress
287
305
) ;
288
306
if ( ! result ) {
289
307
return ;
290
308
}
291
309
292
310
const ipcAddress = result . ipcAddress ;
293
- await context . workspaceState . update ( JS_DEBUG_IPC_KEY , { ipcAddress, jsDebugPath } ) ;
311
+ await context . workspaceState . update (
312
+ JS_DEBUG_IPC_KEY ,
313
+ { ipcAddress, jsDebugPath, settingsValue } as CachedIpcState ,
314
+ ) ;
315
+
294
316
return ipcAddress ;
295
317
}
318
+
319
+ function getJsDebugSettingKey ( ) {
320
+ let o : { [ key : string ] : unknown } = { } ;
321
+ const config = vscode . workspace . getConfiguration ( JS_DEBUG_SETTINGS ) ;
322
+ for ( const setting of JS_DEBUG_REFRESH_SETTINGS ) {
323
+ o [ setting ] = config . get ( setting ) ;
324
+ }
325
+
326
+ return JSON . stringify ( o ) ;
327
+ }
0 commit comments