fix: honour flex-separator in powerline render path#411
Open
ssoriche wants to merge 1 commit into
Open
Conversation
renderPowerlineStatusLine filters out flex-separator widgets at the start of the function and never restores their layout effect, so a configured flex-separator silently has no effect when powerline mode is enabled. The non-powerline render path correctly distributes terminal-width minus content-width across each flex-separator position; this commit teaches the powerline path to do the same. How: - Before filtering, compute a Set of filteredWidgets indices that are immediately followed by a flex-separator in the original widget array. - During the render loop, when one of those indices is reached, emit a closing powerline cap (a triangle in the previous widget's bg colour with no bg of its own) followed by a sentinel string, and skip the regular between-widgets separator. - After the render loop, if any flex positions were marked, split the result string on the sentinel, measure the visible width of each part, distribute the remaining terminal width evenly across the flex positions as spaces, and reassemble. When the terminal width is unknown the sentinels are stripped so they cannot leak. Tests: Four new tests in renderer-flex-width.test.ts cover - single flex-separator in powerline mode - multiple flex-separators in powerline mode - sentinel cleanup when terminal width is unknown - non-powerline path regression check All 585 tests pass (581 existing + 4 new). Lint and tsc are clean.
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.
Summary
renderPowerlineStatusLinefilters outflex-separatorwidgets at the top of the function and never restores their layout effect, so a configuredflex-separatorsilently has no effect when powerline mode is enabled. The non-powerline render path correctly distributes terminal-width minus content-width across eachflex-separatorposition; this PR teaches the powerline path to do the same.Repro
In an existing config, enable
powerline.enabled: trueand place aflex-separatorwidget between two regular widgets. Render against a known terminal width and observe the visible width of the result is content-width, not terminal-width — the flex space is missing.Fix
In
src/utils/renderer.ts, insiderenderPowerlineStatusLine:Set<number>offilteredWidgetsindices that are immediately followed by aflex-separatorin the original widgets array. The widget itself stays filtered (powerline can't render it as a triangle), but the layout intent is preserved.�FLEX_SEP�sentinel. Skip the regular between-widgets separator at that boundary.terminalWidth − totalContentWidthevenly across the flex positions as spaces, and reassemble. When the terminal width is unknown the sentinels are stripped so they can't leak into the output.The non-powerline path is unchanged.
Test plan
Four new tests in
src/utils/__tests__/renderer-flex-width.test.ts:distributes remaining width across a flex-separator in powerline mode— single flex, asserts visible width equals the effective render width (terminalWidth − 6forflexMode: 'full').distributes space across multiple flex-separators in powerline mode— three sections separated by two flex-separators, total visible width still matches effective width.strips flex-separator markers when terminal width is unknown— sentinel never leaks into output when no width is detected.still works in non-powerline mode (no regression)— sanity check on the existing path.All 585 tests pass (
bun test) — 581 existing + 4 newTypeScript checks clean (
bun tsc --noEmit)ESLint clean (
bun run lint)Manually verified in a real Claude Code session (visible width fills to
terminalWidth − 6as expected)