@@ -11,7 +11,7 @@ import { List } from 'vs/base/browser/ui/list/listWidget';
11
11
import { CancelablePromise , createCancelablePromise , disposableTimeout , TimeoutTimer } from 'vs/base/common/async' ;
12
12
import { onUnexpectedError } from 'vs/base/common/errors' ;
13
13
import { Emitter , Event , PauseableEmitter } from 'vs/base/common/event' ;
14
- import { DisposableStore , IDisposable } from 'vs/base/common/lifecycle' ;
14
+ import { DisposableStore , IDisposable , MutableDisposable } from 'vs/base/common/lifecycle' ;
15
15
import { clamp } from 'vs/base/common/numbers' ;
16
16
import * as strings from 'vs/base/common/strings' ;
17
17
import 'vs/css!./media/suggest' ;
@@ -104,6 +104,8 @@ export class SuggestWidget implements IDisposable {
104
104
private _state : State = State . Hidden ;
105
105
private _isAuto : boolean = false ;
106
106
private _loadingTimeout ?: IDisposable ;
107
+ private readonly _pendingLayout = new MutableDisposable ( ) ;
108
+ private readonly _pendingShowDetails = new MutableDisposable ( ) ;
107
109
private _currentSuggestionDetails ?: CancelablePromise < void > ;
108
110
private _focusedItem ?: CompletionItem ;
109
111
private _ignoreFocusEvents : boolean = false ;
@@ -300,6 +302,8 @@ export class SuggestWidget implements IDisposable {
300
302
this . _status . dispose ( ) ;
301
303
this . _disposables . dispose ( ) ;
302
304
this . _loadingTimeout ?. dispose ( ) ;
305
+ this . _pendingLayout . dispose ( ) ;
306
+ this . _pendingShowDetails . dispose ( ) ;
303
307
this . _showTimeout . dispose ( ) ;
304
308
this . _contentWidget . dispose ( ) ;
305
309
this . element . dispose ( ) ;
@@ -559,9 +563,12 @@ export class SuggestWidget implements IDisposable {
559
563
this . _onDidSelect . resume ( ) ;
560
564
}
561
565
562
- this . _layout ( this . element . size ) ;
563
- // Reset focus border
564
- this . _details . widget . domNode . classList . remove ( 'focused' ) ;
566
+ this . _pendingLayout . value = dom . runAtThisOrScheduleAtNextAnimationFrame ( ( ) => {
567
+ this . _pendingLayout . clear ( ) ;
568
+ this . _layout ( this . element . size ) ;
569
+ // Reset focus border
570
+ this . _details . widget . domNode . classList . remove ( 'focused' ) ;
571
+ } ) ;
565
572
}
566
573
567
574
selectNextPage ( ) : boolean {
@@ -678,6 +685,7 @@ export class SuggestWidget implements IDisposable {
678
685
toggleDetails ( ) : void {
679
686
if ( this . _isDetailsVisible ( ) ) {
680
687
// hide details widget
688
+ this . _pendingShowDetails . clear ( ) ;
681
689
this . _ctxSuggestWidgetDetailsVisible . set ( false ) ;
682
690
this . _setDetailsVisible ( false ) ;
683
691
this . _details . hide ( ) ;
@@ -692,15 +700,18 @@ export class SuggestWidget implements IDisposable {
692
700
}
693
701
694
702
showDetails ( loading : boolean ) : void {
695
- this . _details . show ( ) ;
696
- if ( loading ) {
697
- this . _details . widget . renderLoading ( ) ;
698
- } else {
699
- this . _details . widget . renderItem ( this . _list . getFocusedElements ( ) [ 0 ] , this . _explainMode ) ;
700
- }
701
- this . _positionDetails ( ) ;
702
- this . editor . focus ( ) ;
703
- this . element . domNode . classList . add ( 'shows-details' ) ;
703
+ this . _pendingShowDetails . value = dom . runAtThisOrScheduleAtNextAnimationFrame ( ( ) => {
704
+ this . _pendingShowDetails . clear ( ) ;
705
+ this . _details . show ( ) ;
706
+ if ( loading ) {
707
+ this . _details . widget . renderLoading ( ) ;
708
+ } else {
709
+ this . _details . widget . renderItem ( this . _list . getFocusedElements ( ) [ 0 ] , this . _explainMode ) ;
710
+ }
711
+ this . _positionDetails ( ) ;
712
+ this . editor . focus ( ) ;
713
+ this . element . domNode . classList . add ( 'shows-details' ) ;
714
+ } ) ;
704
715
}
705
716
706
717
toggleExplainMode ( ) : void {
@@ -719,7 +730,10 @@ export class SuggestWidget implements IDisposable {
719
730
}
720
731
721
732
hideWidget ( ) : void {
733
+ this . _pendingLayout . clear ( ) ;
734
+ this . _pendingShowDetails . clear ( ) ;
722
735
this . _loadingTimeout ?. dispose ( ) ;
736
+
723
737
this . _setState ( State . Hidden ) ;
724
738
this . _onDidHide . fire ( this ) ;
725
739
this . element . clearSashHoverState ( ) ;
0 commit comments