Skip to content

Commit

Permalink
use editor's font strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Feb 5, 2025
1 parent d53355a commit 9ada392
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/vs/editor/common/config/fontInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 9ada392

Please sign in to comment.