feat(extensions): add host-owned file-view syntax highlighting - #1053
feat(extensions): add host-owned file-view syntax highlighting#1053benvinegar wants to merge 23 commits into
Conversation
|
Too many files changed for review (57 files, 50 file limit). Bypass the limit by tagging |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
100f8f5 to
4bd8d8e
Compare
|
Tested #1053 with hunk-viewed's full-file view (unified and split, old and new documents, search spans interleaved): tokenization, exact-text validation and fallback all behave as documented. Thanks. One gap for diff-presenting views: a token color always overrides Two smaller points: a single span/text mismatch rejects the whole layout, so extensions must re-verify every reference; dropping |
Summary
Closes #1023.
File-view extensions can now declare complete code documents and map symbolic spans to exact UTF-16 source slices. Hunk retains ownership of language detection, Shiki/Pierre tokenization, active-theme colors, worker scheduling, caching, terminal safety, projection, and plain-text fallback.
This enables source, generated-code, blame, Markdown-fence, guttered, and split old/new presentations without exposing token colors or renderer internals to extensions.
Approach
codeDocumentsandspan.syntaxcontract with bounded validation, normalization, immutable snapshots, and exact text matching.hunkdiffChangeset.Important invariants and non-goals
sourceRangesremain note/navigation bindings and are independent from syntax references.Validation
Passed after rebasing onto current
main:bun run typecheckbun run lintbun run deps:checkbun run check:packbun run check:docsbun run website:checkbun run changeset:statusbun run test:integration— 174 passed, 1 platform skipbun run test:tty-smoke— 10 passedgit diff --check origin/main...HEADFocused unit, React lifecycle, service/worker, compiled-worker, consumer, and FileView projection/geometry suites also passed throughout implementation. The new file-view PTY case verifies real syntax colors, multiline offscreen lexical state, theme changes, resize, refresh generations, cross-file navigation, and exact viewport stability.
bun run testretains one environment-dependent failure in unchangedpackages/hunk/src/extensions/hostRuntimeModules.test.ts:179: this machine has an external/tmp/node_modules/react, so the test's deliberately outside-extension import resolves. The failing file is unchanged frommain; the two shards otherwise reported 1,882 and 2,379 passing tests, respectively.Platform and visual evidence
Follow-up adopter
A reviewed
hunk-viewedmigration exists locally and uses complete old/new documents for its unified and split full-file views. Its release is intentionally sequenced after the next minorhunkdiffrelease publishes API v26.This PR description was generated by Pi using gpt-5.6-sol