Skip to content

fix(powerline): fall back to a plain | separator when no Powerline font is detected - #13

Merged
axisrow merged 1 commit into
mainfrom
fix/separator-font-fallback
Sep 26, 2026
Merged

axisrow merged 1 commit into
mainfrom
fix/separator-font-fallback

Conversation

@axisrow

@axisrow axisrow commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Closes the bug half of sirmalloc#604 (the feature half is handled by sirmalloc#607).

Problem

The default powerline separator is the private-use-area glyph U+E0B0. Without a Powerline/Nerd Font it renders as mojibake, and while checkPowerlineFonts() can detect the absence of fonts, that warning only surfaced in the TUI setup flow — enabling powerline via config/CLI on a machine without fonts produced garbage glyphs in every render with no hint of the cause. Regular-mode separators suffer the same when users type PUA characters as their separator.

Fix

Render-time font-safe pass, applied to:

  • powerline separators, startCaps, endCaps (renderer's powerline path);
  • regular-mode separator character and defaultSeparator (renderer's regular path).

Mechanics:

  • fontSafeSeparator(): text containing a PUA glyph (BMP PUA U+E000–F8FF plus the astral Nerd Font planes) degrades to '|' when the detection reports no font; everything else passes through untouched, and glyphs are kept when a font is detected.
  • Detection (checkPowerlineFonts(), a directory scan) is cached for the process lifetime so renders stay cheap; installPowerlineFonts() resets the cache so newly installed fonts stop the fallback.
  • setCachedPowerlineFontStatus() is a small test seam: tests pin the detection result, so renderer output is deterministic regardless of the machine's fonts (several existing glyph-asserting tests now seed installed: true).

Known limitation

Detection is disk-based (font directories + name patterns) — it cannot know which font the terminal actually uses. A machine with a Nerd Font installed on disk but a non-Nerd font selected in the terminal will keep the glyphs (and the mojibake). Surfacing a hint in that case would need a config knob or TUI message; left out to keep this change small.

Verification

  • New separator-font-fallback.test.ts: glyph detection (BMP + astral), fallback with fonts absent, pass-through with fonts present, and full renders in powerline mode and regular mode (PUA separator character) asserting | and no U+E0B0.
  • Existing glyph-asserting tests (renderer-dim, renderer-flex-width) pinned via the test seam — all green.
  • bun test full suite: only the pre-existing timing-flaky subprocess tests flicker (pass in isolation); bun run lint clean; bun run build OK.
  • Live: a powerline-enabled config with U+E0B0 separators rendered through the built binary on a font-less machine emits | and zero mojibake bytes.

🤖 Generated with Claude Code

…nt is detected

Powerline/Nerd Font glyphs (private-use area) render as mojibake when the
terminal has no matching font; checkPowerlineFonts() could detect this,
but only the TUI setup flow surfaced it. Now every powerline separator,
cap, and user-typed separator character is checked at render time: PUA
glyphs degrade to '|' when no font is detected and pass through
untouched otherwise. Detection is a directory scan, cached for the
process lifetime; installing fonts through the TUI resets the cache.
Tests can pin the detection via setCachedPowerlineFontStatus() so
renders stay deterministic regardless of the machine's fonts.

Closes the bug half of sirmalloc#604.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@axisrow
axisrow merged commit 74ba67f into main Sep 26, 2026
4 of 6 checks passed
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.

1 participant