fix(painter-dom): keep the empty-line caret on the start of RTL lines - #3950
Open
palmoni5 wants to merge 1 commit into
Open
fix(painter-dom): keep the empty-line caret on the start of RTL lines#3950palmoni5 wants to merge 1 commit into
palmoni5 wants to merge 1 commit into
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
palmoni5
force-pushed
the
fix/rtl-empty-line-caret
branch
from
August 31, 2026 23:40
9174af6 to
7f7c03f
Compare
An empty line is painted with a `superdoc-empty-run` span that carries the line's PM positions. The span was filled with a non-breaking space, which has a real advance width, and the caret for an empty line is drawn at the span's left edge. On an LTR line that edge is the line start, so the space is invisible; on an RTL line the line starts at the right edge, so the caret lands one space width inside the line instead of on its start. Measured in a Hebrew document at 16px Arial: the line box ended at x=697.7 and the caret sat at x=693.3, the placeholder's left edge, 4.4px off the start. The gap scales with the font size, so it grows with zoom and larger text. Fill the placeholder with a zero-width space instead. It keeps the span's font metrics, and with them the caret's height, while contributing no advance, so the caret lands on the line start in both directions.
palmoni5
force-pushed
the
fix/rtl-empty-line-caret
branch
from
August 31, 2026 23:41
7f7c03f to
ee43a9f
Compare
Author
|
I have read the CLA Document and I hereby sign the CLA |
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.
The bug
Put the caret on an empty paragraph in a right-to-left document and it does not
sit on the start of the line. It sits a space width inside it.
Cause
renderLinepaints an empty line with asuperdoc-empty-runspan that carriesthe line's PM positions, and fills it with
:A non-breaking space has a real advance width, and the caret for an empty line
is drawn at the placeholder's left edge. On an LTR line that edge is the line
start, so nothing shows. On an RTL line the line starts at the right edge, so
the caret ends up one space width inside the line.
Measured
A Hebrew document, Arial 16px, empty paragraph after a line of text:
.superdoc-empty-runbox4.4px off the start, exactly the placeholder's width and exactly its left edge.
Two checks that it really is the placeholder's advance driving the caret, both
done from the page with CSS only, no code change:
.superdoc-empty-run { letter-spacing: 20px }→ placeholder box widens to673.3 → 697.7, caret moves to 673.3. It tracks the box.
The gap is proportional to the font size, so it grows with zoom and with larger
text.
Fix
Fill the placeholder with a zero-width space. It keeps the span's font metrics,
and with them the caret's height (measured: unchanged at 17px), while
contributing no advance, so the caret lands on the line start in both
directions.
Tests
renderLine empty-line placeholderinrender-line.test.ts— assertsthe zero-width filler and the preserved
pmStart/pmEnd, on an LTR and anRTL line. Both fail on
mainand pass with the fix.index.test.ts.packages/layout-engine/painters/domsuite: 61 files, 1547 tests, all pass.One note on how I ran them:
vpwould not start on my machine (Windows, Node22.20) — it fails resolving
#module-sync-enabledout ofvite-plus-corebefore it reads any config — so I ran the painter suite with the workspace
vitestdirectly, using the aliases fromvite.sourceResolve.ts. For the samereason I could not run
pnpm run format:checkorpnpm run lint; the changefollows the surrounding style and stays well inside the line width used in the
file.