Skip to content

Commit 9ada392

Browse files
committed
use editor's font strategy
1 parent d53355a commit 9ada392

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/vs/editor/common/config/fontInfo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import { EditorZoom } from './editorZoom.js';
1111
* Determined from empirical observations.
1212
* @internal
1313
*/
14-
const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35;
14+
export const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35;
1515

1616
/**
1717
* @internal
1818
*/
19-
const MINIMUM_LINE_HEIGHT = 8;
19+
export const MINIMUM_LINE_HEIGHT = 8;
2020

2121
/**
2222
* @internal

src/vs/workbench/contrib/terminalContrib/suggest/browser/terminalSuggestAddon.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { ThemeIcon } from '../../../../../base/common/themables.js';
3333
import { MenuId } from '../../../../../platform/actions/common/actions.js';
3434
import { ISimpleSuggestWidgetFontInfo } from '../../../../services/suggest/browser/simpleSuggestWidgetRenderer.js';
3535
import { ITerminalConfigurationService } from '../../../terminal/browser/terminal.js';
36+
import { GOLDEN_LINE_HEIGHT_RATIO, MINIMUM_LINE_HEIGHT } from '../../../../../editor/common/config/fontInfo.js';
3637

3738
export interface ISuggestController {
3839
isPasting: boolean;
@@ -391,10 +392,16 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
391392
const fontWeight: string = this._configurationService.getValue('editor.fontWeight');
392393

393394
if (lineHeight <= 1) {
394-
// Scale so icon shows by default
395-
lineHeight = fontSize < 16 ? Math.ceil(fontSize * 1.5) : fontSize;
396-
} else if (lineHeight <= 8) {
397-
lineHeight = fontSize * lineHeight;
395+
lineHeight = GOLDEN_LINE_HEIGHT_RATIO * fontSize;
396+
} else if (lineHeight < MINIMUM_LINE_HEIGHT) {
397+
// Values too small to be line heights in pixels are in ems.
398+
lineHeight = lineHeight * fontSize;
399+
}
400+
401+
// Enforce integer, minimum constraints
402+
lineHeight = Math.round(lineHeight);
403+
if (lineHeight < MINIMUM_LINE_HEIGHT) {
404+
lineHeight = MINIMUM_LINE_HEIGHT;
398405
}
399406

400407
const fontInfo = {

0 commit comments

Comments
 (0)