@@ -14,6 +14,7 @@ import { IClipboardService } from '../../../../platform/clipboard/common/clipboa
14
14
import { ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js' ;
15
15
import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js' ;
16
16
import { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js' ;
17
+ import { ILogService } from '../../../../platform/log/common/log.js' ;
17
18
import { IProductService } from '../../../../platform/product/common/productService.js' ;
18
19
import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js' ;
19
20
import { CopyOptions , InMemoryClipboardMetadataManager } from '../../../browser/controller/editContext/clipboardUtils.js' ;
@@ -171,6 +172,8 @@ class ExecCommandCopyWithSyntaxHighlightingAction extends EditorAction {
171
172
}
172
173
173
174
public run ( accessor : ServicesAccessor , editor : ICodeEditor ) : void {
175
+ const logService = accessor . get ( ILogService ) ;
176
+ logService . trace ( 'ExecCommandCopyWithSyntaxHighlightingAction#run' ) ;
174
177
if ( ! editor . hasModel ( ) ) {
175
178
return ;
176
179
}
@@ -183,7 +186,9 @@ class ExecCommandCopyWithSyntaxHighlightingAction extends EditorAction {
183
186
184
187
CopyOptions . forceCopyWithSyntaxHighlighting = true ;
185
188
editor . focus ( ) ;
189
+ logService . trace ( 'ExecCommandCopyWithSyntaxHighlightingAction (before execCommand copy)' ) ;
186
190
editor . getContainerDomNode ( ) . ownerDocument . execCommand ( 'copy' ) ;
191
+ logService . trace ( 'ExecCommandCopyWithSyntaxHighlightingAction (after execCommand copy)' ) ;
187
192
CopyOptions . forceCopyWithSyntaxHighlighting = false ;
188
193
}
189
194
}
@@ -195,6 +200,8 @@ function registerExecCommandImpl(target: MultiCommand | undefined, browserComman
195
200
196
201
// 1. handle case when focus is in editor.
197
202
target . addImplementation ( 10000 , 'code-editor' , ( accessor : ServicesAccessor , args : any ) => {
203
+ const logService = accessor . get ( ILogService ) ;
204
+ logService . trace ( 'registerExecCommandImpl (addImplementation code-editor for : ' , browserCommand , ')' ) ;
198
205
// Only if editor text focus (i.e. not if editor has widget focus).
199
206
const focusedEditor = accessor . get ( ICodeEditorService ) . getFocusedCodeEditor ( ) ;
200
207
if ( focusedEditor && focusedEditor . hasTextFocus ( ) ) {
@@ -207,10 +214,14 @@ function registerExecCommandImpl(target: MultiCommand | undefined, browserComman
207
214
// TODO this is very ugly. The entire copy/paste/cut system needs a complete refactoring.
208
215
if ( focusedEditor . getOption ( EditorOption . effectiveEditContext ) && browserCommand === 'cut' ) {
209
216
// execCommand(copy) works for edit context, but not execCommand(cut).
217
+ logService . trace ( 'registerExecCommandImpl (before execCommand copy)' ) ;
210
218
focusedEditor . getContainerDomNode ( ) . ownerDocument . execCommand ( 'copy' ) ;
211
219
focusedEditor . trigger ( undefined , Handler . Cut , undefined ) ;
220
+ logService . trace ( 'registerExecCommandImpl (after execCommand copy)' ) ;
212
221
} else {
222
+ logService . trace ( 'registerExecCommandImpl (before execCommand ' + browserCommand + ')' ) ;
213
223
focusedEditor . getContainerDomNode ( ) . ownerDocument . execCommand ( browserCommand ) ;
224
+ logService . trace ( 'registerExecCommandImpl (after execCommand ' + browserCommand + ')' ) ;
214
225
}
215
226
return true ;
216
227
}
@@ -219,7 +230,11 @@ function registerExecCommandImpl(target: MultiCommand | undefined, browserComman
219
230
220
231
// 2. (default) handle case when focus is somewhere else.
221
232
target . addImplementation ( 0 , 'generic-dom' , ( accessor : ServicesAccessor , args : any ) => {
233
+ const logService = accessor . get ( ILogService ) ;
234
+ logService . trace ( 'registerExecCommandImpl (addImplementation generic-dom for : ' , browserCommand , ')' ) ;
235
+ logService . trace ( 'registerExecCommandImpl (before execCommand ' + browserCommand + ')' ) ;
222
236
getActiveDocument ( ) . execCommand ( browserCommand ) ;
237
+ logService . trace ( 'registerExecCommandImpl (after execCommand ' + browserCommand + ')' ) ;
223
238
return true ;
224
239
} ) ;
225
240
}
@@ -230,6 +245,8 @@ registerExecCommandImpl(CopyAction, 'copy');
230
245
if ( PasteAction ) {
231
246
// 1. Paste: handle case when focus is in editor.
232
247
PasteAction . addImplementation ( 10000 , 'code-editor' , ( accessor : ServicesAccessor , args : any ) => {
248
+ const logService = accessor . get ( ILogService ) ;
249
+ logService . trace ( 'registerExecCommandImpl (addImplementation code-editor for : paste)' ) ;
233
250
const codeEditorService = accessor . get ( ICodeEditorService ) ;
234
251
const clipboardService = accessor . get ( IClipboardService ) ;
235
252
const telemetryService = accessor . get ( ITelemetryService ) ;
@@ -248,10 +265,12 @@ if (PasteAction) {
248
265
}
249
266
250
267
const sw = StopWatch . create ( true ) ;
268
+ logService . trace ( 'registerExecCommandImpl (before triggerPaste)' ) ;
251
269
const triggerPaste = clipboardService . triggerPaste ( getActiveWindow ( ) . vscodeWindowId ) ;
252
270
if ( triggerPaste ) {
271
+ logService . trace ( 'registerExecCommandImpl (triggerPaste defined)' ) ;
253
272
return triggerPaste . then ( async ( ) => {
254
-
273
+ logService . trace ( 'registerExecCommandImpl (after triggerPaste)' ) ;
255
274
if ( productService . quality !== 'stable' ) {
256
275
const duration = sw . elapsed ( ) ;
257
276
type EditorAsyncPasteClassification = {
@@ -270,8 +289,11 @@ if (PasteAction) {
270
289
271
290
return CopyPasteController . get ( focusedEditor ) ?. finishedPaste ( ) ?? Promise . resolve ( ) ;
272
291
} ) ;
292
+ } else {
293
+ logService . trace ( 'registerExecCommandImpl (triggerPaste undefined)' ) ;
273
294
}
274
295
if ( platform . isWeb ) {
296
+ logService . trace ( 'registerExecCommandImpl (Paste handling on web)' ) ;
275
297
// Use the clipboard service if document.execCommand('paste') was not successful
276
298
return ( async ( ) => {
277
299
const clipboardText = await clipboardService . readText ( ) ;
@@ -285,6 +307,7 @@ if (PasteAction) {
285
307
multicursorText = ( typeof metadata . multicursorText !== 'undefined' ? metadata . multicursorText : null ) ;
286
308
mode = metadata . mode ;
287
309
}
310
+ logService . trace ( 'registerExecCommandImpl (clipboardText.length : ' , clipboardText . length , ' id : ' , metadata ?. id , ')' ) ;
288
311
focusedEditor . trigger ( 'keyboard' , Handler . Paste , {
289
312
text : clipboardText ,
290
313
pasteOnNewLine,
@@ -301,6 +324,8 @@ if (PasteAction) {
301
324
302
325
// 2. Paste: (default) handle case when focus is somewhere else.
303
326
PasteAction . addImplementation ( 0 , 'generic-dom' , ( accessor : ServicesAccessor , args : any ) => {
327
+ const logService = accessor . get ( ILogService ) ;
328
+ logService . trace ( 'registerExecCommandImpl (addImplementation generic-dom for : paste)' ) ;
304
329
const triggerPaste = accessor . get ( IClipboardService ) . triggerPaste ( getActiveWindow ( ) . vscodeWindowId ) ;
305
330
return triggerPaste ?? false ;
306
331
} ) ;
0 commit comments