fixed css for font family (#15119)

This commit is contained in:
Aditya Bist
2021-04-13 18:37:55 -07:00
committed by GitHub
parent 58d0add46f
commit 90868bc0ad
6 changed files with 61 additions and 23 deletions

View File

@@ -808,7 +808,23 @@ export class ViewModel extends Disposable implements IViewModel {
const fontInfo = this._configuration.options.get(EditorOption.fontInfo);
const colorMap = this._getColorMap();
const fontFamily = fontInfo.fontFamily === EDITOR_FONT_DEFAULTS.fontFamily ? fontInfo.fontFamily : `'${fontInfo.fontFamily}', ${EDITOR_FONT_DEFAULTS.fontFamily}`;
const hasBadChars = (/[:;\\\/<>]/.test(fontInfo.fontFamily));
const useDefaultFontFamily = (hasBadChars || fontInfo.fontFamily === EDITOR_FONT_DEFAULTS.fontFamily);
let fontFamily: string;
if (useDefaultFontFamily) {
fontFamily = EDITOR_FONT_DEFAULTS.fontFamily;
} else {
fontFamily = fontInfo.fontFamily;
fontFamily = fontFamily.replace(/"/g, '\'');
const hasQuotesOrIsList = /[,']/.test(fontFamily);
if (!hasQuotesOrIsList) {
const needsQuotes = /[+ ]/.test(fontFamily);
if (needsQuotes) {
fontFamily = `'${fontFamily}'`;
}
}
fontFamily = `${fontFamily}, ${EDITOR_FONT_DEFAULTS.fontFamily}`;
}
return {
mode: languageId.language,