Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential divison by zero when calculating heightMetrics #51

Closed
wants to merge 1 commit into from
Closed

Conversation

ly4k
Copy link

@ly4k ly4k commented Apr 15, 2023

FIX: Fixes an issue where the Gutter Element breaks due to a divsion by zero (codemirror/dev#1132)

this.height seems to always have the same value as this.height whenever a line does not wrap. This prevents the division by zero by setting the value of perChar to 0, which is always the value whenever the line does not wrap.

FIX: Fixes an issue where the Gutter Element breaks due to a divsion by zero (codemirror/dev#1132)
@marijnh
Copy link
Member

marijnh commented Apr 16, 2023

Isn't it safer to check whether the divisor (this.length - lines - 1), rather than the denominator, is zero here?

@ly4k
Copy link
Author

ly4k commented Apr 16, 2023

Yes, you're absolutely right. That would indeed be the safer option. Do you want me to update it or can you do it?

@marijnh marijnh closed this in 637b424 Apr 16, 2023
@marijnh
Copy link
Member

marijnh commented Apr 16, 2023

Done in attached patch.

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.

2 participants