Skip to content

editor: Left-align tab whitespace marker instead of centering it#57658

Open
mvanhorn wants to merge 1 commit into
zed-industries:mainfrom
mvanhorn:fix/57087-zed-tab-invisible-left-align
Open

editor: Left-align tab whitespace marker instead of centering it#57658
mvanhorn wants to merge 1 commit into
zed-industries:mainfrom
mvanhorn:fix/57087-zed-tab-invisible-left-align

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments (N/A)
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Tab whitespace markers (e.g. `→`) were being centered against `em_width` along with space markers. For tabs that span multiple columns (especially with proportional fonts), this pushed the arrow into the middle of the tab cell instead of aligning it where the tab actually begins, making it visually hard to tell tab from space.

Extracted the per-character centering offset into `invisible_marker_offset` and made it return zero for tabs while preserving the existing centering for spaces. Refactored `extract_whitespace_info` to use a new `invisible_paint_info` helper so the position math is shared between the renderer and the new tests.

Tests cover both branches: tabs paint at `x_for_index(start)` exactly, spaces keep their centering offset. The whitespace-map test setup is reused.

Closes #57087

Release Notes:

  • Fixed - Tab whitespace markers are now left-aligned instead of centered, matching the visual position of the tab character.

AI was used for assistance.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 25, 2026
@maxdeviant maxdeviant changed the title fix: left-align tab whitespace marker instead of centering it editor: Left-align tab whitespace marker instead of centering it May 25, 2026
@maxdeviant
Copy link
Copy Markdown
Member

@mvanhorn Could you please add before and after screenshots of the change?

@mvanhorn
Copy link
Copy Markdown
Contributor Author

@maxdeviant here's the before/after with show_whitespaces: "all" and the same demo file (mixed real-tab + space lines).

Side-by-side: https://files.catbox.moe/p9oxex.png

Before (stable main): https://files.catbox.moe/hmqoio.png
After (this PR, built from a0a7f46): https://files.catbox.moe/q2nklx.png

Demo file:

A\tB\tC\tD
\thello\tworld
\t\tdouble\ttab
    space indent

In the BEFORE shot the tab arrow sits centered inside the tab cell (you can see it offset rightward from where the tab actually starts). In the AFTER shot the arrow is at the left edge - so the tab marker visually starts where the tab character starts, instead of drifting into the middle of the cell. The space dots are unchanged.

@smitbarmase smitbarmase added the area:editor Feedback for code editing, formatting, editor iterations, etc label May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:editor Feedback for code editing, formatting, editor iterations, etc cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hard tab whitespace character is now centered

3 participants