Fix: Use same amount of left pad as .cm-line - #33
Open
mattmundell wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
Note that the same happens in the Replit UI. It's easiest to see when choosing a Font Size of The red box is the cursor. It's an outline because the view does not have the focus. The grey line should align with the left of the cursor. Maybe clearer when I modify Compare with a Font Size of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Why
The indent markers are drawn using backgrounds on a
::beforeelement that is placed on CodeMirror lines (.cm-line). The left offsets of the indent markers should match the left pad of the.cm-line, however there is an error in the calculation.The left offset of the indent marker is made up of:
0.5chthat is added to the left offset of the background increateGradient2pxthat is set as the left value of the::beforeelement.The
2pxwas added in #26 by @bradymadden97 to try fix the alignment but if you look closely at theme.tx#L85 the.cm-lineleft pad is6pxinstead of2px.The offset of



0.5chplus2pxis coming close, but see for example how the line under the 6 is shifting as I increase the font size:(Maybe zoom the first image yourself to see how far left it should be.)
This is because the size of
0.5chdepends on the font size, whereas the CodeMirror.cm-lineoffset is always fixed at 6 pixels.What changed
Remove the extra
0.5choffset from the background and change the::beforeleft from2pxto6px.Test plan
I tested using an app that uses CodeMirror. I enabled the indentation markers and then gradually increased the font size to confirm the drift.
After the PR the line stays in place when I increase the font size:


