feat: add Hunk-backed diff viewing - #7
Merged
Merged
Conversation
Renderers that must be told their width — a Hunk diff block, say — had no way to learn it: `CodeBlockRendererProps` carried the block's indent but not its columns. `MarkdownView` now measures the terminal, subtracts the row-document gutter and the scrollbar reserve, and passes each block the columns left inside `CodeBlockChrome`. Flex-sized renderers can keep ignoring it. Also exports `SourceIndex` so packages outside `@tooee/renderers` can build source spans for their own row models.
Wraps Hunk's public OpenTUI primitives (`hunkdiff/opentui`, pinned exactly because Hunk is pre-1.0) behind one package so no other Tooee package imports it. `buildDiffModel` parses unified patch text into navigation rows — one per file header, one per `@@` hunk — each carrying its own patch text and its span in the original patch, recovered by scanning the same text since Hunk exposes no source positions. A hunk row hands Hunk a copy of its file narrowed to a single hunk while keeping the whole-file line arrays, so line numbers and collapsed-gap counts still resolve against the complete file. Files Hunk renders without hunks (binary, too large, untracked) get one body row. `DiffView` renders those rows into a `row-document`, which stays the only scroll owner, so the cursor, search decorations, marks, scroll-follow and mouse routing keep working over diff rows. `diffCodeBlockRenderer` draws ```diff and ```patch Markdown fences the same way, falling back to the default code block when the fence body is not a real unified diff. Known limits — per-hunk line-number column width, approximated themes, and Hunk's install weight — are documented in the package README.
`.patch`/`.diff` files — and patch text sniffed from stdin or an unhelpful extension — now open a first-class diff subview instead of plain text. `DiffSubview` runs a document controller over the diff rows, so `j`/`k` step hunk by hunk, search and copy work in real patch text, and the status bar shows file count, totals, layout and the current file:hunk. Commands: `s` toggles split/unified, `w` toggles wrapping, `]`/`[` jump between files, `f` opens a fuzzy file picker, and `h`/`l` pan wide hunks. The picker sets the cursor through `navigation.setCursor` rather than `selectRow`, which stands down while the modal overlay that owns the picker is still open. ```diff and ```patch fences in Markdown render as diff blocks by default; a host's own `codeBlockRenderers` entry still wins.
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
@tooee/diffwith Hunk-backed stacked and split patch rendering--renderer diffdiffandpatchMarkdown fences through HunkVerification
bun run checkbun run lint:checkbun run format:checkbun run testgit diff --check 953dbf0..36d72f5Release
Includes a Tegami minor release note for the shared Tooee package group.