@@ -280,6 +280,12 @@ export class CommonFindController extends Disposable implements IEditorContribut
280
280
281
281
if ( ! stateChanges . searchString && opts . seedSearchStringFromGlobalClipboard ) {
282
282
let selectionSearchString = await this . getGlobalBufferTerm ( ) ;
283
+
284
+ if ( ! this . _editor . hasModel ( ) ) {
285
+ // the editor has lost its model in the meantime
286
+ return ;
287
+ }
288
+
283
289
if ( selectionSearchString ) {
284
290
stateChanges . searchString = selectionSearchString ;
285
291
}
@@ -364,13 +370,14 @@ export class CommonFindController extends Disposable implements IEditorContribut
364
370
return '' ;
365
371
}
366
372
367
- public async setGlobalBufferTerm ( text : string ) {
373
+ public setGlobalBufferTerm ( text : string ) : void {
368
374
if ( this . _editor . getOption ( EditorOption . find ) . globalFindClipboard
369
375
&& this . _clipboardService
370
376
&& this . _editor . hasModel ( )
371
377
&& ! this . _editor . getModel ( ) . isTooLargeForSyncing ( )
372
378
) {
373
- await this . _clipboardService . writeFindText ( text ) ;
379
+ // intentionally not awaited
380
+ this . _clipboardService . writeFindText ( text ) ;
374
381
}
375
382
}
376
383
}
@@ -424,10 +431,12 @@ export class FindController extends CommonFindController implements IFindControl
424
431
425
432
await super . _start ( opts ) ;
426
433
427
- if ( opts . shouldFocus === FindStartFocusAction . FocusReplaceInput ) {
428
- this . _widget ! . focusReplaceInput ( ) ;
429
- } else if ( opts . shouldFocus === FindStartFocusAction . FocusFindInput ) {
430
- this . _widget ! . focusFindInput ( ) ;
434
+ if ( this . _widget ) {
435
+ if ( opts . shouldFocus === FindStartFocusAction . FocusReplaceInput ) {
436
+ this . _widget . focusReplaceInput ( ) ;
437
+ } else if ( opts . shouldFocus === FindStartFocusAction . FocusFindInput ) {
438
+ this . _widget . focusFindInput ( ) ;
439
+ }
431
440
}
432
441
}
433
442
@@ -470,10 +479,10 @@ export class StartFindAction extends EditorAction {
470
479
} ) ;
471
480
}
472
481
473
- public run ( accessor : ServicesAccessor | null , editor : ICodeEditor ) : void {
482
+ public async run ( accessor : ServicesAccessor | null , editor : ICodeEditor ) : Promise < void > {
474
483
let controller = CommonFindController . get ( editor ) ;
475
484
if ( controller ) {
476
- controller . start ( {
485
+ await controller . start ( {
477
486
forceRevealReplace : false ,
478
487
seedSearchStringFromSelection : editor . getOption ( EditorOption . find ) . seedSearchStringFromSelection ,
479
488
seedSearchStringFromGlobalClipboard : editor . getOption ( EditorOption . find ) . globalFindClipboard ,
@@ -508,7 +517,7 @@ export class StartFindWithSelectionAction extends EditorAction {
508
517
public async run ( accessor : ServicesAccessor , editor : ICodeEditor ) : Promise < void > {
509
518
let controller = CommonFindController . get ( editor ) ;
510
519
if ( controller ) {
511
- controller . start ( {
520
+ await controller . start ( {
512
521
forceRevealReplace : false ,
513
522
seedSearchStringFromSelection : true ,
514
523
seedSearchStringFromGlobalClipboard : false ,
@@ -518,15 +527,15 @@ export class StartFindWithSelectionAction extends EditorAction {
518
527
loop : editor . getOption ( EditorOption . find ) . loop
519
528
} ) ;
520
529
521
- return controller . setGlobalBufferTerm ( controller . getState ( ) . searchString ) ;
530
+ controller . setGlobalBufferTerm ( controller . getState ( ) . searchString ) ;
522
531
}
523
532
}
524
533
}
525
534
export abstract class MatchFindAction extends EditorAction {
526
- public run ( accessor : ServicesAccessor | null , editor : ICodeEditor ) : void {
535
+ public async run ( accessor : ServicesAccessor | null , editor : ICodeEditor ) : Promise < void > {
527
536
let controller = CommonFindController . get ( editor ) ;
528
537
if ( controller && ! this . _run ( controller ) ) {
529
- controller . start ( {
538
+ await controller . start ( {
530
539
forceRevealReplace : false ,
531
540
seedSearchStringFromSelection : ( controller . getState ( ) . searchString . length === 0 ) && editor . getOption ( EditorOption . find ) . seedSearchStringFromSelection ,
532
541
seedSearchStringFromGlobalClipboard : true ,
@@ -629,7 +638,7 @@ export class PreviousMatchFindAction2 extends MatchFindAction {
629
638
}
630
639
631
640
export abstract class SelectionMatchFindAction extends EditorAction {
632
- public run ( accessor : ServicesAccessor | null , editor : ICodeEditor ) : void {
641
+ public async run ( accessor : ServicesAccessor | null , editor : ICodeEditor ) : Promise < void > {
633
642
let controller = CommonFindController . get ( editor ) ;
634
643
if ( ! controller ) {
635
644
return ;
@@ -639,7 +648,7 @@ export abstract class SelectionMatchFindAction extends EditorAction {
639
648
controller . setSearchString ( selectionSearchString ) ;
640
649
}
641
650
if ( ! this . _run ( controller ) ) {
642
- controller . start ( {
651
+ await controller . start ( {
643
652
forceRevealReplace : false ,
644
653
seedSearchStringFromSelection : editor . getOption ( EditorOption . find ) . seedSearchStringFromSelection ,
645
654
seedSearchStringFromGlobalClipboard : false ,
@@ -720,7 +729,7 @@ export class StartFindReplaceAction extends EditorAction {
720
729
} ) ;
721
730
}
722
731
723
- public run ( accessor : ServicesAccessor | null , editor : ICodeEditor ) : void {
732
+ public async run ( accessor : ServicesAccessor | null , editor : ICodeEditor ) : Promise < void > {
724
733
if ( ! editor . hasModel ( ) || editor . getOption ( EditorOption . readOnly ) ) {
725
734
return ;
726
735
}
@@ -745,7 +754,7 @@ export class StartFindReplaceAction extends EditorAction {
745
754
746
755
747
756
if ( controller ) {
748
- controller . start ( {
757
+ await controller . start ( {
749
758
forceRevealReplace : true ,
750
759
seedSearchStringFromSelection : seedSearchStringFromSelection ,
751
760
seedSearchStringFromGlobalClipboard : editor . getOption ( EditorOption . find ) . seedSearchStringFromSelection ,
0 commit comments