From 9ada39268affdffefbf6286a6ade13d6ed802323 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Wed, 5 Feb 2025 16:28:19 -0600 Subject: [PATCH] use editor's font strategy --- src/vs/editor/common/config/fontInfo.ts | 4 ++-- .../suggest/browser/terminalSuggestAddon.ts | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/vs/editor/common/config/fontInfo.ts b/src/vs/editor/common/config/fontInfo.ts index 6854c5f76725e..eae8d0891ddf9 100644 --- a/src/vs/editor/common/config/fontInfo.ts +++ b/src/vs/editor/common/config/fontInfo.ts @@ -11,12 +11,12 @@ import { EditorZoom } from './editorZoom.js'; * Determined from empirical observations. * @internal */ -const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35; +export const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35; /** * @internal */ -const MINIMUM_LINE_HEIGHT = 8; +export const MINIMUM_LINE_HEIGHT = 8; /** * @internal diff --git a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts index 59976c6b05efb..9c93bbc13fd3a 100644 --- a/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts +++ b/src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts @@ -33,6 +33,7 @@ import { ThemeIcon } from '../../../../../base/common/themables.js'; import { MenuId } from '../../../../../platform/actions/common/actions.js'; import { ISimpleSuggestWidgetFontInfo } from '../../../../services/suggest/browser/simpleSuggestWidgetRenderer.js'; import { ITerminalConfigurationService } from '../../../terminal/browser/terminal.js'; +import { GOLDEN_LINE_HEIGHT_RATIO, MINIMUM_LINE_HEIGHT } from '../../../../../editor/common/config/fontInfo.js'; export interface ISuggestController { isPasting: boolean; @@ -391,10 +392,16 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest const fontWeight: string = this._configurationService.getValue('editor.fontWeight'); if (lineHeight <= 1) { - // Scale so icon shows by default - lineHeight = fontSize < 16 ? Math.ceil(fontSize * 1.5) : fontSize; - } else if (lineHeight <= 8) { - lineHeight = fontSize * lineHeight; + lineHeight = GOLDEN_LINE_HEIGHT_RATIO * fontSize; + } else if (lineHeight < MINIMUM_LINE_HEIGHT) { + // Values too small to be line heights in pixels are in ems. + lineHeight = lineHeight * fontSize; + } + + // Enforce integer, minimum constraints + lineHeight = Math.round(lineHeight); + if (lineHeight < MINIMUM_LINE_HEIGHT) { + lineHeight = MINIMUM_LINE_HEIGHT; } const fontInfo = {