I’m trying to figure out an edge case regarding this feature (https://github.com/microsoft/vscode/issues/193857). One edge case I found is that when the user changes the notebook.markup.fontSize
, the notebook.markdown.lineHeight
also needs to be adjusted to prevent merged text. However, the notebook.markup.fontSize
‘s value is set using a conditional. There are two options I can think of to work with this, but I’m not sure which is the most acceptable.
The current value of notebook-markup-font-size
:
'notebook-markup-font-size': typeof this.options.markupFontSize === 'number' && this.options.markupFontSize > 0 ? `${this.options.markupFontSize}px` : `calc(${this.options.fontSize}px * 1.2)`,
Option 1: Store the ternary operator conditional for notebook-markup-font-size
in a variable and use that variable for both the notebook-markup-font-size
and ‘notebook-cell-output-line-height`.
Option 1
private _generateStyles() {
let fontSizeStr = typeof this.options.markupFontSize === 'number' && this.options.markupFontSize > 0 ? `${this.options.markupFontSize}px` : `calc(${this.options.fontSize}px * 1.2)`;
return {
'notebook-markup-font-size': `${fontSizeStr}`,
'notebook-markdown-line-height': typeof this.options.markdownLineHeight === 'number' && this.options.markdownLineHeight > 0 ?
`${this.options.markdownLineHeight}px` : `calc(${fontSizeStr})px * 1.5 `
}
Option 2: Set the else
value for notebook-cell-output-line-height
to undefined
. This will automatically adjust the lineHeight in markdown cells as if no custom setting for this was ever implemented.
Option 2
private _generateStyles() {
let fontSizeStr = typeof this.options.markupFontSize === 'number' && this.options.markupFontSize > 0 ? `${this.options.markupFontSize}px` : `calc(${this.options.fontSize}px * 1.2)`;
return {
'notebook-markup-font-size': `${fontSizeStr}`,
'notebook-markdown-line-height': typeof this.options.markdownLineHeight === 'number' && this.options.markdownLineHeight > 0 ? `${this.options.markdownLineHeight}px` : `calc(${fontSizeStr})px * 1.5 `
}
}
Both methods will work, but I don’t know what the best practice in this case would be, so any advice would be really appreciated!
Dat Nguyen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.