Skip to content

Commit bd09ca9

Browse files
committed
Run suggestWidget.showSuggestions' layout on an animation frame
This prevents double rendering, both in the keypress task and the following animation frame Part of microsoft#161622
1 parent 38b89a1 commit bd09ca9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/vs/editor/contrib/suggest/browser/suggestWidget.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export class SuggestWidget implements IDisposable {
104104
private _state: State = State.Hidden;
105105
private _isAuto: boolean = false;
106106
private _loadingTimeout?: IDisposable;
107+
private _pendingLayout?: IDisposable;
107108
private _currentSuggestionDetails?: CancelablePromise<void>;
108109
private _focusedItem?: CompletionItem;
109110
private _ignoreFocusEvents: boolean = false;
@@ -559,9 +560,13 @@ export class SuggestWidget implements IDisposable {
559560
this._onDidSelect.resume();
560561
}
561562

562-
this._layout(this.element.size);
563-
// Reset focus border
564-
this._details.widget.domNode.classList.remove('focused');
563+
this._pendingLayout?.dispose();
564+
this._pendingLayout = dom.runAtThisOrScheduleAtNextAnimationFrame(() => {
565+
this._pendingLayout = undefined;
566+
this._layout(this.element.size);
567+
// Reset focus border
568+
this._details.widget.domNode.classList.remove('focused');
569+
});
565570
}
566571

567572
selectNextPage(): boolean {

0 commit comments

Comments
 (0)