Skip to content

fix(renderer): drop spacing separator stranded against a flex-separator - #567

Open
tough-griff wants to merge 1 commit into
sirmalloc:mainfrom
tough-griff:pr/flex-separator-spacing
Open

fix(renderer): drop spacing separator stranded against a flex-separator#567
tough-griff wants to merge 1 commit into
sirmalloc:mainfrom
tough-griff:pr/flex-separator-spacing

Conversation

@tough-griff

Copy link
Copy Markdown

Fixes #566.

Problem

A spacing-only separator (character: " ") that sits between a widget which renders nothing and a flex-separator is not collapsed. The separator-collapse logic in renderStatusLine only walks backward for preceding content, so the spacing separator finds the widget before it and is emitted; it never notices that the flex-separator immediately after it (once the empty widget in between is filtered out) will provide its own spacing.

With a known terminal width the flex-separator expands to fill the line and the extra space vanishes into the gap. With no terminal width (piped / no TTY — how Claude Code normally calls the status line) each flex-separator falls back to rendering " | ", and the leftover space shows up as a visible double space:

… ↑2  | account@example.com      (before)
… ↑2 | account@example.com       (after)

Fix

After the existing trailing-separator trim, walk elements once and drop any spacing-only separator (isSpacingSeparator) that is directly adjacent to a flex-separator. By that point empty widgets have already been filtered out of elements, so "adjacent to a flex-separator" is exactly the stranded-separator case. Visible separators (|, :, …) are left untouched so they can still act as an explicit boundary.

This also very slightly improves the width-known path: the stray space was previously counted in totalContentLength, shrinking the distributed flex gap by one column.

Tests

  • New regression test in renderer-separator-collapse.test.ts exercising the zero-width flex fallback (terminalWidth: 0), which the existing collapse/flex tests never cover.
  • bun test green, bun run lint clean.

When the widget between a spacing-only separator and a flex-separator
renders nothing, the separator survived the backward-only collapse logic.
In the no-width flex fallback (piped/no-TTY, the common case under Claude
Code) this produced a visible double space before the fallback " | ".

Add a pass after trailing-separator trimming that removes spacing-only
separators sitting directly against a flex-separator in the assembled
elements array.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wu2bixWqAAfsMR72ttgZQA
(cherry picked from commit bc6b5c36a19e6b58fb0cf00292394215f9cc5ad4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stray double space before a flex-separator when the preceding widget renders nothing

1 participant