Skip to content

Commit cd17786

Browse files
authored
Revert "Add list of strings option to editor.fontFamily (microsoft#164289)" (microsoft#167462)
This reverts commit 2212e36. Fixes microsoft#167132
1 parent f9928a1 commit cd17786

File tree

9 files changed

+17
-73
lines changed

9 files changed

+17
-73
lines changed

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

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ export interface IEditorOptions {
620620
/**
621621
* The font family
622622
*/
623-
fontFamily?: string | string[];
623+
fontFamily?: string;
624624
/**
625625
* The font weight
626626
*/
@@ -1616,44 +1616,6 @@ export class EditorFontLigatures extends BaseEditorOption<EditorOption.fontLigat
16161616

16171617
//#endregion
16181618

1619-
//#region fontFamily
1620-
/**
1621-
* @internal
1622-
*/
1623-
export class EditorFontFamily extends BaseEditorOption<EditorOption.fontFamily, string | string[], string> {
1624-
constructor() {
1625-
super(
1626-
EditorOption.fontFamily, 'fontFamily', EDITOR_FONT_DEFAULTS.fontFamily,
1627-
{
1628-
anyOf: [
1629-
{
1630-
type: 'string',
1631-
},
1632-
{
1633-
type: 'array',
1634-
items: {
1635-
type: 'string',
1636-
},
1637-
}
1638-
],
1639-
description: nls.localize('fontFamily', "Controls the font family."),
1640-
default: EDITOR_FONT_DEFAULTS.fontFamily
1641-
}
1642-
);
1643-
}
1644-
public validate(input: any): string {
1645-
if (typeof input === 'string') {
1646-
return input;
1647-
}
1648-
if (Array.isArray(input) && input.length > 0) {
1649-
return input.map((f: string) => { return JSON.stringify(f); }).join(',');
1650-
}
1651-
return this.defaultValue;
1652-
}
1653-
}
1654-
1655-
//#endregion
1656-
16571619
//#region fontVariations
16581620

16591621
/**
@@ -5140,7 +5102,10 @@ export const EditorOptions = {
51405102
EditorOption.unfoldOnClickAfterEndOfLine, 'unfoldOnClickAfterEndOfLine', false,
51415103
{ description: nls.localize('unfoldOnClickAfterEndOfLine', "Controls whether clicking on the empty content after a folded line will unfold the line.") }
51425104
)),
5143-
fontFamily: register(new EditorFontFamily()),
5105+
fontFamily: register(new EditorStringOption(
5106+
EditorOption.fontFamily, 'fontFamily', EDITOR_FONT_DEFAULTS.fontFamily,
5107+
{ description: nls.localize('fontFamily', "Controls the font family.") }
5108+
)),
51445109
fontInfo: register(new EditorFontInfo()),
51455110
fontLigatures2: register(new EditorFontLigatures()),
51465111
fontSize: register(new EditorFontSize()),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class BareFontInfo {
4545
/**
4646
* @internal
4747
*/
48-
public static createFromRawSettings(opts: { fontFamily?: string | string[]; fontWeight?: string; fontSize?: number; fontLigatures?: boolean | string; fontVariations?: boolean | string; lineHeight?: number; letterSpacing?: number }, pixelRatio: number, ignoreEditorZoom: boolean = false): BareFontInfo {
48+
public static createFromRawSettings(opts: { fontFamily?: string; fontWeight?: string; fontSize?: number; fontLigatures?: boolean | string; fontVariations?: boolean | string; lineHeight?: number; letterSpacing?: number }, pixelRatio: number, ignoreEditorZoom: boolean = false): BareFontInfo {
4949
const fontFamily = EditorOptions.fontFamily.validate(opts.fontFamily);
5050
const fontWeight = EditorOptions.fontWeight.validate(opts.fontWeight);
5151
const fontSize = EditorOptions.fontSize.validate(opts.fontSize);

src/vs/monaco.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3581,7 +3581,7 @@ declare namespace monaco.editor {
35813581
/**
35823582
* The font family
35833583
*/
3584-
fontFamily?: string | string[];
3584+
fontFamily?: string;
35853585
/**
35863586
* The font weight
35873587
*/

src/vs/workbench/contrib/notebook/browser/view/cellParts/cellComments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { coalesce } from 'vs/base/common/arrays';
77
import { DisposableStore } from 'vs/base/common/lifecycle';
8-
import { EditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
8+
import { EDITOR_FONT_DEFAULTS, IEditorOptions } from 'vs/editor/common/config/editorOptions';
99
import * as languages from 'vs/editor/common/languages';
1010
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1111
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
@@ -70,7 +70,7 @@ export class CellComments extends CellContentPart {
7070
commentThread,
7171
null,
7272
{
73-
codeBlockFontFamily: EditorOptions.fontFamily.validate(this.configurationService.getValue<IEditorOptions>('editor').fontFamily)
73+
codeBlockFontFamily: this.configurationService.getValue<IEditorOptions>('editor').fontFamily || EDITOR_FONT_DEFAULTS.fontFamily
7474
},
7575
undefined,
7676
{

src/vs/workbench/contrib/scm/browser/scmViewPane.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ import { DropIntoEditorController } from 'vs/editor/contrib/dropIntoEditor/brows
8989
import { MessageController } from 'vs/editor/contrib/message/browser/messageController';
9090
import { contrastBorder, registerColor } from 'vs/platform/theme/common/colorRegistry';
9191
import { defaultButtonStyles } from 'vs/platform/theme/browser/defaultStyles';
92-
import { EditorOptions } from 'vs/editor/common/config/editorOptions';
9392

9493
type TreeElement = ISCMRepository | ISCMInput | ISCMActionButton | ISCMResourceGroup | IResourceNode<ISCMResource, ISCMResourceGroup> | ISCMResource;
9594

@@ -2148,7 +2147,7 @@ class SCMInputWidget {
21482147
const inputFontFamily = this.configurationService.getValue<string>('scm.inputFontFamily').trim();
21492148

21502149
if (inputFontFamily.toLowerCase() === 'editor') {
2151-
return EditorOptions.fontFamily.validate(this.configurationService.getValue<string | string[]>('editor.fontFamily')).trim();
2150+
return this.configurationService.getValue<string>('editor.fontFamily').trim();
21522151
}
21532152

21542153
if (inputFontFamily.length !== 0 && inputFontFamily.toLowerCase() !== 'default') {

src/vs/workbench/contrib/terminal/browser/terminalConfigHelper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as nls from 'vs/nls';
7-
import { EditorOptions, EDITOR_FONT_DEFAULTS, IEditorOptions } from 'vs/editor/common/config/editorOptions';
7+
import { EDITOR_FONT_DEFAULTS, IEditorOptions } from 'vs/editor/common/config/editorOptions';
88
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
99
import { ITerminalConfiguration, TERMINAL_CONFIG_SECTION, DEFAULT_LETTER_SPACING, DEFAULT_LINE_HEIGHT, MINIMUM_LETTER_SPACING, MINIMUM_FONT_WEIGHT, MAXIMUM_FONT_WEIGHT, DEFAULT_FONT_WEIGHT, DEFAULT_BOLD_FONT_WEIGHT, FontWeight, ITerminalFont } from 'vs/workbench/contrib/terminal/common/terminal';
1010
import Severity from 'vs/base/common/severity';
@@ -71,7 +71,7 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
7171

7272
configFontIsMonospace(): boolean {
7373
const fontSize = 15;
74-
const fontFamily = this.config.fontFamily || EditorOptions.fontFamily.validate(this._configurationService.getValue<IEditorOptions>('editor').fontFamily);
74+
const fontFamily = this.config.fontFamily || this._configurationService.getValue<IEditorOptions>('editor').fontFamily || EDITOR_FONT_DEFAULTS.fontFamily;
7575
const iRect = this._getBoundingRectFor('i', fontFamily, fontSize);
7676
const wRect = this._getBoundingRectFor('w', fontFamily, fontSize);
7777

@@ -155,7 +155,7 @@ export class TerminalConfigHelper implements IBrowserTerminalConfigHelper {
155155
getFont(xtermCore?: IXtermCore, excludeDimensions?: boolean): ITerminalFont {
156156
const editorConfig = this._configurationService.getValue<IEditorOptions>('editor');
157157

158-
let fontFamily = this.config.fontFamily || EditorOptions.fontFamily.validate(editorConfig.fontFamily);
158+
let fontFamily = this.config.fontFamily || editorConfig.fontFamily || EDITOR_FONT_DEFAULTS.fontFamily;
159159
let fontSize = this._clampInt(this.config.fontSize, MINIMUM_FONT_SIZE, MAXIMUM_FONT_SIZE, EDITOR_FONT_DEFAULTS.fontSize);
160160

161161
// Work around bad font on Fedora/Ubuntu

src/vs/workbench/contrib/webview/browser/themeing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { Emitter } from 'vs/base/common/event';
77
import { Disposable } from 'vs/base/common/lifecycle';
8-
import { EditorOptions, EDITOR_FONT_DEFAULTS, IEditorOptions } from 'vs/editor/common/config/editorOptions';
8+
import { EDITOR_FONT_DEFAULTS, IEditorOptions } from 'vs/editor/common/config/editorOptions';
99
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1010
import * as colorRegistry from 'vs/platform/theme/common/colorRegistry';
1111
import { ColorScheme } from 'vs/platform/theme/common/theme';
@@ -52,7 +52,7 @@ export class WebviewThemeDataProvider extends Disposable {
5252
public getWebviewThemeData(): WebviewThemeData {
5353
if (!this._cachedWebViewThemeData) {
5454
const configuration = this._configurationService.getValue<IEditorOptions>('editor');
55-
const editorFontFamily = EditorOptions.fontFamily.validate(configuration.fontFamily);
55+
const editorFontFamily = configuration.fontFamily || EDITOR_FONT_DEFAULTS.fontFamily;
5656
const editorFontWeight = configuration.fontWeight || EDITOR_FONT_DEFAULTS.fontWeight;
5757
const editorFontSize = configuration.fontSize || EDITOR_FONT_DEFAULTS.fontSize;
5858

src/vs/workbench/services/configurationResolver/test/electron-browser/configurationResolverService.test.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -280,26 +280,6 @@ suite('Configuration Resolver Service', () => {
280280
}
281281
});
282282

283-
test('substitute one env variable as array and a configuration variable', async () => {
284-
const configurationService = new TestConfigurationService({
285-
editor: {
286-
fontFamily: ['foo']
287-
},
288-
terminal: {
289-
integrated: {
290-
fontFamily: 'bar'
291-
}
292-
}
293-
});
294-
295-
const service = new TestConfigurationResolverService(nullContext, Promise.resolve(environmentService.userEnv), new TestEditorServiceWithActiveEditor(), configurationService, mockCommandService, new TestContextService(), quickInputService, labelService, pathService, extensionService);
296-
if (platform.isWindows) {
297-
assert.strictEqual(await service.resolveAsync(workspace, 'abc ${config:editor.fontFamily} ${workspaceFolder} ${env:key1} xyz'), 'abc foo \\VSCode\\workspaceLocation Value for key1 xyz');
298-
} else {
299-
assert.strictEqual(await service.resolveAsync(workspace, 'abc ${config:editor.fontFamily} ${workspaceFolder} ${env:key1} xyz'), 'abc foo /VSCode/workspaceLocation Value for key1 xyz');
300-
}
301-
});
302-
303283
test('substitute many env variable and a configuration variable', async () => {
304284
const configurationService = new TestConfigurationService({
305285
editor: {

src/vs/workbench/services/hover/browser/hoverWidget.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
1010
import { IHoverTarget, IHoverOptions } from 'vs/workbench/services/hover/browser/hover';
1111
import { KeyCode } from 'vs/base/common/keyCodes';
1212
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
13-
import { EditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
13+
import { EDITOR_FONT_DEFAULTS, IEditorOptions } from 'vs/editor/common/config/editorOptions';
1414
import { HoverAction, HoverPosition, HoverWidget as BaseHoverWidget } from 'vs/base/browser/ui/hover/hoverWidget';
1515
import { Widget } from 'vs/base/browser/ui/widget';
1616
import { AnchorPosition } from 'vs/base/browser/ui/contextview/contextview';
@@ -138,7 +138,7 @@ export class HoverWidget extends Widget {
138138
const markdown = options.content;
139139
const mdRenderer = this._instantiationService.createInstance(
140140
MarkdownRenderer,
141-
{ codeBlockFontFamily: EditorOptions.fontFamily.validate(this._configurationService.getValue<IEditorOptions>('editor').fontFamily) }
141+
{ codeBlockFontFamily: this._configurationService.getValue<IEditorOptions>('editor').fontFamily || EDITOR_FONT_DEFAULTS.fontFamily }
142142
);
143143

144144
const { element } = mdRenderer.render(markdown, {

0 commit comments

Comments
 (0)