Skip to content

Commit 014076a

Browse files
committed
Avoid some potential divisions by zero in height estimates
Issue #72
1 parent 1819167 commit 014076a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/heightmap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class HeightOracle {
2828

2929
heightForLine(length: number): number {
3030
if (!this.lineWrapping) return this.lineHeight
31-
let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)))
31+
let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / Math.max(1, this.lineLength - 5)))
3232
return lines * this.lineHeight
3333
}
3434

src/viewstate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export class ViewState {
326326
if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {
327327
let {lineHeight, charWidth, textHeight} = view.docView.measureTextSize()
328328
refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight,
329-
contentWidth / charWidth, lineHeights)
329+
Math.max(5, contentWidth / charWidth), lineHeights)
330330
if (refresh) {
331331
view.docView.minWidth = 0
332332
result |= UpdateFlag.Geometry

0 commit comments

Comments
 (0)