Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Fix #3478: Persistent highlight is taller than transient highlight #3568

Merged
merged 3 commits into from
May 8, 2013

Conversation

TomMalbran
Copy link
Contributor

The problem in #3478 was that when the font-size increased the font-size line-height ratio was lost. They line height should always be 1.25 times higher than the font-size so that the text would fit inside the line.

I applied the solution to the font adjustment instead of the styles, to make it possible to keep using pixels for both font size and line height. If we can change the line-height to ems, an easier solution would be to just remove all the line-height adjustments in the command function.

@ghost ghost assigned redmunds May 7, 2013
var lhStr = lhNew + lhUnits;

// Don't let the font size get too small or too large.
if (fsNew < MIN_FONT_SIZE * delta || fsNew > MAX_FONT_SIZE * delta) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maximum px size is 72, otherwise 7.2. This works for px and em, but if anyone changes units to anything else, the results may not be desirable. Maybe this should check for units type (like it did before).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing would actually work for other units, and that is why the code is returned on line 151 when the units aren't px or em, so this check wasn't that necessary. If a new font size unit would be introduced the whole code would need to be updated to support it, so I don't think this is an issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this is a bit cryptic, so please explain the 72 vs 7.2 in a comment.

@redmunds
Copy link
Contributor

redmunds commented May 7, 2013

If we can change the line-height to ems, an easier solution would be to just
remove all the line-height adjustments in the command function.

The problem is keeping it the same as the line numbers. This should be a separate change.

@redmunds
Copy link
Contributor

redmunds commented May 7, 2013

Done with initial review.

@TomMalbran
Copy link
Contributor Author

@redmunds Thanks for the review.

I added a comment there. The comment needs to be updated, but I don't think that the if does need to go back to how it was. Let me know if there might still be good to have it work as before.

The problem is keeping it the same as the line numbers. This should be a separate change.

Actually since the line numbers are now part of the code lines, the text adjustment are made to both at the same time making the em solution work. I did made a quick test in the Developer Tools. But this would also fix the problem so we don't really need to use the alternative solution.

@redmunds
Copy link
Contributor

redmunds commented May 7, 2013

I didn't see the check for px and em at the top, so no need to check again for MIN/MAX.

@redmunds
Copy link
Contributor

redmunds commented May 7, 2013

It's nice that line numbers are in same element as code so they can never get out-of-sync.

Update the comment for min max explaining maximum size is 72px or 7.2 em and I'll merge it.

@TomMalbran
Copy link
Contributor Author

@redmunds done :)

/**
* @const
* @private
* The proportion between the font-size and the line-height in pixels
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that his comment is not quite correct. The operands are reversed, and it's not in pixels (it's a ratio).

It should be "The ratio of line-height to font-size".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I intended to use it just for px, but then I realized that it would be required for ems too, when both units are ems. I'll update this comment too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better: "The ratio of line-height to font-size when font-size is in pixels"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it is used when both font-size and line-height are in px or ems, and is not when they are different. If the font-size is on px and the line-height in ems, the line height doesn't change. So the previous one is more accurate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still bugs me that the operands are reversed. How about: "The ratio of line-height to font-size when the use the same units"

@redmunds
Copy link
Contributor

redmunds commented May 7, 2013

@TomMalbran 1 last comment change.

@TomMalbran
Copy link
Contributor Author

@redmunds Comment updated.

@redmunds
Copy link
Contributor

redmunds commented May 8, 2013

Merging.

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants