feat: file preview with syntax highlighting#57
Conversation
Vendor @speed-highlight/core for terminal ANSI syntax highlighting. Supports 38 languages with auto-detection by file extension. Zero runtime dependencies - library is vendored. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| const lang = detectLang(node.name) | ||
| if (lang !== "plain") { | ||
| try { | ||
| content = await highlightText(text, lang) |
There was a problem hiding this comment.
Because highlightText() is async, preview mode is no longer entered atomically. onKey() fires showPreview() and returns immediately, but the stdin listener is only swapped after the await resolves. On larger files, any keys pressed during highlighting are still handled by the main picker, so users can move the cursor, toggle selections, or even quit before the preview opens. It would be safer to either await showPreview() from an async key handler or detach onKey before starting the highlight work.
|
Review score: 6.5/10\n\nThe feature direction is strong and the repo still builds and passes the full test suite ( |
| } else { | ||
| content = raw.toString("utf-8") | ||
| const text = raw.toString("utf-8") | ||
| const lang = detectLang(node.name) |
There was a problem hiding this comment.
Highlighting changes content from plain text to ANSI-colored text, but the preview code below still calculates width and truncates with plain string slicing. For long lines that means escape sequences can be cut in half or counted as visible columns, which corrupts the preview and can leak colors into following rows. This path probably needs ANSI-aware width/slice handling before we ship colored previews.
Summary
@speed-highlight/corefor terminal ANSI syntax highlighting (zero runtime deps)Size impact
Full Changelog: stacked on #feat/file-preview
🤖 Generated with Claude Code