Skip to content

Conversation

@DrRataplan
Copy link

@DrRataplan DrRataplan commented Dec 5, 2025

This sometimes occurs in Firefox when a codemirror view is invisible initially. The rect does have a usable height, but the width is zero. This causes a set of Infinity and NaN values later in the flow.

Be more robust against that: default it to a sensible value.

I manually verified this fixes codemirror/dev#1642. Since this codeflow is only hit in a case where everything errors out later anyway I'm quite confident about this fix.

This sometimes occurs in Firefox when a codemirror view is invisible initially. The rect does have a
usable height, but the width is zero. This causes a set of Infinity and NaN values later in the
flow.

Be more robust against that: default it to a sensible value.
@marijnh
Copy link
Member

marijnh commented Dec 5, 2025

How about just charWidth = rect && rect.width ? rect.width / 27 : 7, for simplicity?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error in Firefox caused by a charWidth:0 in measureTextSize

2 participants