From 7d6e919d67d6edf159f762f1f951b52c18bd315d Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Fri, 26 Jul 2024 05:59:33 -0700 Subject: [PATCH] Cache font info to avoid excessive layout Fixes #223876 Fixes #223871 --- .../suggest/browser/terminalSuggestAddon.ts | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts index 002af73a65379..70b3c21fb3c3c 100644 --- a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts +++ b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts @@ -505,21 +505,20 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest private _ensureSuggestWidget(terminal: Terminal): SimpleSuggestWidget { this._terminalSuggestWidgetVisibleContextKey.set(true); if (!this._suggestWidget) { + const c = this._terminalConfigurationService.config; + const font = this._terminalConfigurationService.getFont(dom.getActiveWindow()); + const fontInfo = { + fontFamily: font.fontFamily, + fontSize: font.fontSize, + lineHeight: Math.ceil(1.5 * font.fontSize), + fontWeight: c.fontWeight.toString(), + letterSpacing: font.letterSpacing + }; this._suggestWidget = this._register(this._instantiationService.createInstance( SimpleSuggestWidget, this._panel!, this._instantiationService.createInstance(PersistedWidgetSize), - () => { - const c = this._terminalConfigurationService.config; - const font = this._terminalConfigurationService.getFont(dom.getActiveWindow()); - return { - fontFamily: font.fontFamily, - fontSize: font.fontSize, - lineHeight: Math.ceil(1.5 * font.fontSize), - fontWeight: c.fontWeight.toString(), - letterSpacing: font.letterSpacing - }; - }, + () => fontInfo, {} )); this._suggestWidget.list.style(getListStyles({