@@ -25,6 +25,7 @@ import { NewSymbolName, NewSymbolNameTag, ProviderResult } from 'vs/editor/commo
25
25
import { localize } from 'vs/nls' ;
26
26
import { IContextKey , IContextKeyService , RawContextKey } from 'vs/platform/contextkey/common/contextkey' ;
27
27
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
28
+ import { ILogService } from 'vs/platform/log/common/log' ;
28
29
import { defaultListStyles } from 'vs/platform/theme/browser/defaultStyles' ;
29
30
import {
30
31
editorWidgetBackground ,
@@ -72,6 +73,7 @@ export class RenameInputField implements IContentWidget {
72
73
@IThemeService private readonly _themeService : IThemeService ,
73
74
@IKeybindingService private readonly _keybindingService : IKeybindingService ,
74
75
@IContextKeyService contextKeyService : IContextKeyService ,
76
+ @ILogService private readonly _logService : ILogService ,
75
77
) {
76
78
this . _visibleContextKey = CONTEXT_RENAME_INPUT_VISIBLE . bindTo ( contextKeyService ) ;
77
79
this . _focusedContextKey = CONTEXT_RENAME_INPUT_FOCUSED . bindTo ( contextKeyService ) ;
@@ -206,9 +208,10 @@ export class RenameInputField implements IContentWidget {
206
208
}
207
209
208
210
afterRender ( position : ContentWidgetPositionPreference | null ) : void {
211
+ this . _trace ( 'invoking afterRender, position: ' , position ? 'not null' : 'null' ) ;
209
212
if ( position === null ) {
210
213
// cancel rename when input widget isn't rendered anymore
211
- this . cancelInput ( true ) ;
214
+ this . cancelInput ( true , 'afterRender (because position is null)' ) ;
212
215
return ;
213
216
}
214
217
@@ -241,10 +244,12 @@ export class RenameInputField implements IContentWidget {
241
244
private _currentCancelInput ?: ( focusEditor : boolean ) => void ;
242
245
243
246
acceptInput ( wantsPreview : boolean ) : void {
247
+ this . _trace ( `invoking acceptInput` ) ;
244
248
this . _currentAcceptInput ?.( wantsPreview ) ;
245
249
}
246
250
247
- cancelInput ( focusEditor : boolean ) : void {
251
+ cancelInput ( focusEditor : boolean , caller : string ) : void {
252
+ this . _trace ( `invoking cancelInput, caller: ${ caller } , _currentCancelInput: ${ this . _currentAcceptInput ? 'not undefined' : 'undefined' } ` ) ;
248
253
this . _currentCancelInput ?.( focusEditor ) ;
249
254
}
250
255
@@ -280,6 +285,7 @@ export class RenameInputField implements IContentWidget {
280
285
return new Promise < RenameInputFieldResult | boolean > ( resolve => {
281
286
282
287
this . _currentCancelInput = ( focusEditor ) => {
288
+ this . _trace ( 'invoking _currentCancelInput' ) ;
283
289
this . _currentAcceptInput = undefined ;
284
290
this . _currentCancelInput = undefined ;
285
291
this . _candidatesView ?. clearCandidates ( ) ;
@@ -288,12 +294,13 @@ export class RenameInputField implements IContentWidget {
288
294
} ;
289
295
290
296
this . _currentAcceptInput = ( wantsPreview ) => {
297
+ this . _trace ( 'invoking _currentAcceptInput' ) ;
291
298
assertType ( this . _input !== undefined ) ;
292
299
assertType ( this . _candidatesView !== undefined ) ;
293
300
294
301
const candidateName = this . _candidatesView . focusedCandidate ;
295
302
if ( ( candidateName === undefined && this . _input . value === value ) || this . _input . value . trim ( ) . length === 0 ) {
296
- this . cancelInput ( true ) ;
303
+ this . cancelInput ( true , '_currentAcceptInput (because candidateName is undefined or input.value is empty)' ) ;
297
304
return ;
298
305
}
299
306
@@ -307,9 +314,9 @@ export class RenameInputField implements IContentWidget {
307
314
} ) ;
308
315
} ;
309
316
310
- disposeOnDone . add ( cts . token . onCancellationRequested ( ( ) => this . cancelInput ( true ) ) ) ;
317
+ disposeOnDone . add ( cts . token . onCancellationRequested ( ( ) => this . cancelInput ( true , 'cts.token.onCancellationRequested' ) ) ) ;
311
318
if ( ! _sticky ) {
312
- disposeOnDone . add ( this . _editor . onDidBlurEditorWidget ( ( ) => this . cancelInput ( ! this . _domNode ?. ownerDocument . hasFocus ( ) ) ) ) ;
319
+ disposeOnDone . add ( this . _editor . onDidBlurEditorWidget ( ( ) => this . cancelInput ( ! this . _domNode ?. ownerDocument . hasFocus ( ) , 'editor.onDidBlurEditorWidget' ) ) ) ;
313
320
}
314
321
315
322
this . _show ( ) ;
@@ -321,6 +328,7 @@ export class RenameInputField implements IContentWidget {
321
328
}
322
329
323
330
private _show ( ) : void {
331
+ this . _trace ( 'invoking _show' ) ;
324
332
this . _editor . revealLineInCenterIfOutsideViewport ( this . _position ! . lineNumber , ScrollType . Smooth ) ;
325
333
this . _visible = true ;
326
334
this . _visibleContextKey . set ( true ) ;
@@ -335,9 +343,13 @@ export class RenameInputField implements IContentWidget {
335
343
}
336
344
337
345
private async _updateRenameCandidates ( candidates : ProviderResult < NewSymbolName [ ] > [ ] , currentName : string , token : CancellationToken ) {
346
+ const trace = ( ...args : any [ ] ) => this . _trace ( '_updateRenameCandidates' , ...args ) ;
347
+
348
+ trace ( 'start' ) ;
338
349
const namesListResults = await raceCancellation ( Promise . allSettled ( candidates ) , token ) ;
339
350
340
351
if ( namesListResults === undefined ) {
352
+ trace ( 'returning early - received updateRenameCandidates results - undefined' ) ;
341
353
return ;
342
354
}
343
355
@@ -346,27 +358,39 @@ export class RenameInputField implements IContentWidget {
346
358
? namesListResult . value
347
359
: [ ]
348
360
) ;
361
+ trace ( `received updateRenameCandidates results - total (unfiltered) ${ newNames . length } candidates.` ) ;
349
362
350
363
// deduplicate and filter out the current value
351
364
const distinctNames = arrays . distinct ( newNames , v => v . newSymbolName ) ;
365
+ trace ( `distinct candidates - ${ distinctNames . length } candidates.` ) ;
366
+
352
367
const validDistinctNames = distinctNames . filter ( ( { newSymbolName } ) => newSymbolName . trim ( ) . length > 0 && newSymbolName !== this . _input ?. value && newSymbolName !== currentName ) ;
368
+ trace ( `valid distinct candidates - ${ newNames . length } candidates.` ) ;
353
369
354
370
if ( validDistinctNames . length < 1 ) {
371
+ trace ( 'returning early - no valid distinct candidates' ) ;
355
372
return ;
356
373
}
357
374
358
375
// show the candidates
376
+ trace ( 'setting candidates' ) ;
359
377
this . _candidatesView ! . setCandidates ( validDistinctNames ) ;
360
378
361
379
// ask editor to re-layout given that the widget is now of a different size after rendering rename candidates
380
+ trace ( 'asking editor to re-layout' ) ;
362
381
this . _editor . layoutContentWidget ( this ) ;
363
382
}
364
383
365
384
private _hide ( ) : void {
385
+ this . _trace ( 'invoked _hide' ) ;
366
386
this . _visible = false ;
367
387
this . _visibleContextKey . reset ( ) ;
368
388
this . _editor . layoutContentWidget ( this ) ;
369
389
}
390
+
391
+ private _trace ( ...args : any [ ] ) {
392
+ this . _logService . trace ( 'RenameInputField' , ...args ) ;
393
+ }
370
394
}
371
395
372
396
export class CandidatesView {
0 commit comments