File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he
7
7
- fix: explicitly specify completion ranges ([ vscode #243409 ] ( https://github.com/microsoft/vscode/issues/243409 ) )
8
8
- fix: memory leak between debug sessions ([ #2173 ] ( https://github.com/microsoft/vscode-js-debug/issues/2173 ) )
9
9
- fix: support ` npm.scriptRunner: node `
10
+ - fix: copy multiline values as template literals ([ vscode #241008 ] ( https://github.com/microsoft/vscode/issues/241008 ) )
10
11
- fix: support "attach to node process" without wmic.exe and on arm64 ([ vscode #244139 ] ( https://github.com/microsoft/vscode/issues/244139 ) )
11
12
- fix: support webview2 debugging on arm64
12
13
- fix: race condition when opening attached windows ([ vscode #239769 ] ( https://github.com/microsoft/vscode/issues/239769 ) )
Original file line number Diff line number Diff line change @@ -121,8 +121,13 @@ export const serializeForClipboardTmpl = templateFunction(function(
121
121
) ,
122
122
indent . repeat ( level ) + '}' ,
123
123
] . join ( eol ) ;
124
- case 'string' :
125
- return JSON . stringify ( value ) ;
124
+ case 'string' : {
125
+ if ( value . includes ( '\n' ) ) {
126
+ return '`' + value . replace ( / [ ` \\ \\ ] | \$ { / g, '\\$&' ) + '`' ;
127
+ } else {
128
+ return JSON . stringify ( value ) ;
129
+ }
130
+ }
126
131
case 'symbol' :
127
132
return value . toString ( ) ;
128
133
case 'undefined' :
Original file line number Diff line number Diff line change @@ -252,13 +252,18 @@ describe('evaluate', () => {
252
252
'new Date(1665007127286)' : '"2022-10-05T21:58:47.286Z"' ,
253
253
'(() => { const node = document.createElement("div"); node.innerText = "hi"; return node })()' :
254
254
`<div>hi</div>` ,
255
+ '"hello\\nmu`lti${line}"' : '`hello\nmu\\`lti\\${line}`' ,
256
+ } ;
257
+
258
+ const fnCopyExpressions = {
259
+ '"hello"' : 'hello' ,
260
+ '"hello\\nmu`lti${line}"' : 'hello\nmu`lti${line}' ,
255
261
} ;
256
262
257
263
itIntegrates ( 'copy via function' , async ( { r } ) => {
258
264
const p = await r . launchAndLoad ( 'blank' ) ;
259
- p . dap . evaluate ( { expression : 'var x = "hello"; copy(x)' } ) ;
260
- expect ( ( await p . dap . once ( 'copyRequested' ) ) . text ) . to . equal ( 'hello' ) ;
261
- for ( const [ expression , expected ] of Object . entries ( copyExpressions ) ) {
265
+ const mapping = { ...copyExpressions , ...fnCopyExpressions } ;
266
+ for ( const [ expression , expected ] of Object . entries ( mapping ) ) {
262
267
p . dap . evaluate ( { expression : `copy(${ expression } )` } ) ;
263
268
const actual = await p . dap . once ( 'copyRequested' ) ;
264
269
expect ( actual . text ) . to . equal ( expected , expression ) ;
You can’t perform that action at this time.
0 commit comments