mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
fixed css for font family (#15119)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -98,14 +98,19 @@ export class CodeLensContribution implements IEditorContribution {
|
||||
const fontFamily = this._editor.getOption(EditorOption.codeLensFontFamily);
|
||||
const editorFontInfo = this._editor.getOption(EditorOption.fontInfo);
|
||||
|
||||
const fontFamilyVar = `--codelens-font-family${this._styleClassName}`;
|
||||
const fontFeaturesVar = `--codelens-font-features${this._styleClassName}`;
|
||||
|
||||
let newStyle = `
|
||||
.monaco-editor .codelens-decoration.${this._styleClassName} { line-height: ${codeLensHeight}px; font-size: ${fontSize}px; padding-right: ${Math.round(fontSize * 0.5)}px; font-feature-settings: ${editorFontInfo.fontFeatureSettings} }
|
||||
.monaco-editor .codelens-decoration.${this._styleClassName} { line-height: ${codeLensHeight}px; font-size: ${fontSize}px; padding-right: ${Math.round(fontSize * 0.5)}px; font-feature-settings: var(${fontFeaturesVar}) }
|
||||
.monaco-editor .codelens-decoration.${this._styleClassName} span.codicon { line-height: ${codeLensHeight}px; font-size: ${fontSize}px; }
|
||||
`;
|
||||
if (fontFamily) {
|
||||
newStyle += `.monaco-editor .codelens-decoration.${this._styleClassName} { font-family: ${fontFamily}}`;
|
||||
}
|
||||
this._styleElement.textContent = newStyle;
|
||||
this._editor.getContainerDomNode().style.setProperty(fontFamilyVar, fontFamily ?? 'inherit');
|
||||
this._editor.getContainerDomNode().style.setProperty(fontFeaturesVar, editorFontInfo.fontFeatureSettings);
|
||||
|
||||
//
|
||||
this._editor.changeViewZones(accessor => {
|
||||
|
||||
Reference in New Issue
Block a user