Skip to content

Commit 7e5fdfd

Browse files
committed
Ignore zero rectangles in measureTextSize
FIX: Avoid computing a zero character width (leading to divisions by zero) when the editor is hidden and the browser doesn't have a layout for it. Closes codemirror/dev#1642 Closes #75
1 parent b08ca13 commit 7e5fdfd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/docview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ export class DocView {
456456
this.tile.dom.appendChild(dummy)
457457
let rect = clientRectsFor(dummy.firstChild!)[0]
458458
lineHeight = dummy.getBoundingClientRect().height
459-
charWidth = rect ? rect.width / 27 : 7
460-
textHeight = rect ? rect.height : lineHeight
459+
charWidth = rect && rect.width ? rect.width / 27 : 7
460+
textHeight = rect && rect.height ? rect.height : lineHeight
461461
dummy.remove()
462462
})
463463
return {lineHeight, charWidth, textHeight}

0 commit comments

Comments
 (0)