SD-1403 - fix: tab stop breaking line prematurely#1720
SD-1403 - fix: tab stop breaking line prematurely#1720chittolinag wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
💡 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.
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 👍 / 👎.
Before:
After: