Skip to content

Commit

Permalink
Run suggestWidget.showSuggestions' layout on an animation frame
Browse files Browse the repository at this point in the history
This prevents double rendering, both in the keypress task and the following
animation frame

Part of #161622
  • Loading branch information
Tyriar committed Oct 18, 2022
1 parent 38b89a1 commit bd09ca9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/vs/editor/contrib/suggest/browser/suggestWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class SuggestWidget implements IDisposable {
private _state: State = State.Hidden;
private _isAuto: boolean = false;
private _loadingTimeout?: IDisposable;
private _pendingLayout?: IDisposable;
private _currentSuggestionDetails?: CancelablePromise<void>;
private _focusedItem?: CompletionItem;
private _ignoreFocusEvents: boolean = false;
Expand Down Expand Up @@ -559,9 +560,13 @@ export class SuggestWidget implements IDisposable {
this._onDidSelect.resume();
}

this._layout(this.element.size);
// Reset focus border
this._details.widget.domNode.classList.remove('focused');
this._pendingLayout?.dispose();
this._pendingLayout = dom.runAtThisOrScheduleAtNextAnimationFrame(() => {
this._pendingLayout = undefined;
this._layout(this.element.size);
// Reset focus border
this._details.widget.domNode.classList.remove('focused');
});
}

selectNextPage(): boolean {
Expand Down

0 comments on commit bd09ca9

Please sign in to comment.