-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fixed characterHeight calculation, which could cause overflowing #598
Conversation
The previous calculation was simply using the height of the letter W, but wasn't taking into account that each row has a lineHeight, which might be greater. If the lineHeight is .4px off, after many rows, it will cause the proposedGeometry to have an extra row, potentially causing hidden rows (based on layout).
Deferring to @parisk since I don't use the fit addon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @mikesir87!
It seems that the offsetHeight
attribute takes into account the actual height, padding and border of an element, so it does not ignore the parent element's lineHeight
.
My objection with this implementation is that it uses the style
attribute, while it would be better if we could somehow extract the calculated height of the line.
The best would be to either utilize CharMeasure.ts (which is kind of difficult) or at least simulate this behavior here.
You're absolutely correct here. The problem is that http://codepen.io/anon/pen/LWzEYj
Haha... no objections about that here! Does seem like a "hack" of a solution. Looking at how the |
src/addons/fit/fit.js
Outdated
@@ -56,7 +56,7 @@ | |||
subjectRow.innerHTML = 'W'; // Common character for measuring width, although on monospace | |||
characterWidth = subjectRow.getBoundingClientRect().width; | |||
subjectRow.style.display = ''; // Revert style before calculating height, since they differ. | |||
characterHeight = parseFloat(term.rowContainer.style.lineHeight); | |||
characterHeight = term.getBoundingClientRect().height; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
term
is the terminal instance, not the subject row that you will want to measure the height on. I'm afraid this line will crash... 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch and sorry about that... yes, it would crash. Just pushed the fix.
6cbf0b1
to
0cb8ecc
Compare
Looks great now. Thanks a lot @mikesir87! |
The previous calculation was simply using the height of the letter
W, but wasn't taking into account that each row has a lineHeight,
which might be greater. If the lineHeight is .4px off, after many
rows, it will cause the proposedGeometry to have an extra row,
potentially causing hidden rows (based on layout).