02: Migrate src/render.ts to use render/terminal.ts facade - #160
Merged
shouze merged 2 commits intoAug 23, 2026
Conversation
- Replace stripAnsi() inline implementation with import from render/terminal.ts - Replace clipAnsi() inline implementation with import from render/terminal.ts - Replace all stripAnsi(x).length calls with visibleWidth(x) - Replace all clipAnsi(x, n) calls with clipToWidth(x, n) - Update renderHelpOverlay() pad function to use visibleWidth() - Add tests for CJK repository names and emoji in extract paths - Verify background color preservation in active line clipping Fixes: #142
shouze
force-pushed
the
feat/bun14-terminal/02-render
branch
from
August 23, 2026 15:45
084274c to
f17c8bf
Compare
|
Coverage after merging feat/bun14-terminal/02-render into feat/bun14-terminal/01-terminal will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 similar comment
|
Coverage after merging feat/bun14-terminal/02-render into feat/bun14-terminal/01-terminal will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates src/render.ts away from local ANSI-width helpers (stripAnsi / clipAnsi) to the centralized src/render/terminal.ts façade, so terminal column measurement and ANSI-safe clipping are handled consistently across the codebase.
Changes:
- Import and use
visibleWidthandclipToWidthfromsrc/render/terminal.tsfor width calculations and line clipping. - Remove the in-file
stripAnsi/clipAnsiimplementations fromsrc/render.ts. - Update several alignment calculations to use visible-width semantics instead of raw string length.
Suppressed comments (1)
src/render.ts:432
- The re-pick hints line pads using
barPlain.length, which counts UTF-16 code units rather than terminal columns. If a team/candidate label contains wide characters (emoji/CJK), the suffix alignment can drift and the line can wrap unexpectedly. UsevisibleWidth(...)for the pad calculation.
const bar = renderTeamPickHeader(dm.candidates, dm.focusedIndex, barWidth);
const barPlain = stripAnsi(bar);
// Pad between bar content and suffix to keep suffix right-aligned.
const padLen = Math.max(0, barWidth - barPlain.length);
const line = pc.dim(REPICK_PREFIX) + bar + " ".repeat(padLen) + pc.dim(REPICK_SUFFIX);
lines.push(clipToWidth(line, termWidth) + "\n");
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Sébastien HOUZÉ <sebastien.houze@fulll.fr>
|
Coverage after merging feat/bun14-terminal/02-render into feat/bun14-terminal/01-terminal will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
What does this PR do?
How did you verify your code works?