-
Notifications
You must be signed in to change notification settings - Fork 43
SD-1403 - fix: tab stop breaking line prematurely #1720
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
base: main
Are you sure you want to change the base?
SD-1403 - fix: tab stop breaking line prematurely #1720
Conversation
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 46e58dbb9d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const originX = currentLine.width; | ||
| // Use first-line effective indent (accounts for hanging) on first line, body indent otherwise | ||
| const effectiveIndent = lines.length === 0 ? indentLeft + rawFirstLineOffset : indentLeft; | ||
| const absCurrentX = currentLine.width + effectiveIndent; | ||
| const { target, nextIndex, stop } = getNextTabStopPx(absCurrentX, tabStops, tabStopCursor); | ||
| const { target, nextIndex, stop } = getNextTabStopPx(currentLine.width, tabStops, tabStopCursor); | ||
| tabStopCursor = nextIndex; | ||
| const maxAbsWidth = currentLine.maxWidth + effectiveIndent; | ||
| const clampedTarget = Math.min(target, maxAbsWidth); | ||
| const tabAdvance = Math.max(0, clampedTarget - absCurrentX); | ||
| const clampedTarget = Math.min(target, currentLine.maxWidth); | ||
| const tabAdvance = Math.max(0, clampedTarget - currentLine.width); |
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.
Account for first-line indent when resolving tab stops
Tab advancement now uses currentLine.width directly, but currentLine.width is measured from the first-line text start (which includes firstLine - hanging), while buildTabStopsPx only shifts by indentLeft. On paragraphs with a non‑zero first-line or hanging indent, this means the first line’s tab positions are effectively offset by the first-line indent: the tab stop chosen is too far right (and can skip a nearer stop), so tab leaders and aligned text shift by the first-line offset. This is a regression from the prior effectiveIndent path that added rawFirstLineOffset for line 0; you’ll see it on first lines that include tabs.
Useful? React with 👍 / 👎.
harbournick
left a comment
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.
LGTM
Before:
After: