mirror of
https://github.com/atom/atom.git
synced 2026-02-17 18:11:29 -05:00
Don't throw an error when setting an incredibly small lineHeight
Instead, if the measured line height equals 0, default it to 1 so that the editor component doesn't start computing `NaN` or `Infinity` values due to e.g. dividing by 0. We should probably consider sanitizing line heights smaller than a certain threshold, but that's non trivial because line height is expressed as a multiplier of the font size. Also, users may style the `line-height` property via CSS, which may still throw errors when using small values.
This commit is contained in:
@@ -2046,7 +2046,7 @@ class TextEditorComponent {
|
||||
}
|
||||
|
||||
measureCharacterDimensions () {
|
||||
this.measurements.lineHeight = this.refs.characterMeasurementLine.getBoundingClientRect().height
|
||||
this.measurements.lineHeight = Math.max(1, this.refs.characterMeasurementLine.getBoundingClientRect().height)
|
||||
this.measurements.baseCharacterWidth = this.refs.normalWidthCharacterSpan.getBoundingClientRect().width
|
||||
this.measurements.doubleWidthCharacterWidth = this.refs.doubleWidthCharacterSpan.getBoundingClientRect().width
|
||||
this.measurements.halfWidthCharacterWidth = this.refs.halfWidthCharacterSpan.getBoundingClientRect().width
|
||||
|
||||
Reference in New Issue
Block a user