Fix: Use same amount of left pad as .cm-line #33
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
::before
element 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.5ch
that is added to the left offset of the background increateGradient
2px
that is set as the left value of the::before
element.The
2px
was added in #26 by @bradymadden97 to try fix the alignment but if you look closely at theme.tx#L85 the.cm-line
left pad is6px
instead of2px
.The offset of



0.5ch
plus2px
is 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.5ch
depends on the font size, whereas the CodeMirror.cm-line
offset is always fixed at 6 pixels.What changed
Remove the extra
0.5ch
offset from the background and change the::before
left from2px
to6px
.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:


