Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/diff-rework.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@fuzdev/fuz_util': minor
---

Rebuild `diff.ts` around greedy Myers (breaking):

- `diff_lines` replaces the LCS table with greedy Myers over interned lines — linear memory, common prefix/suffix trimming, and a `max_cost` cap that degrades gracefully to a replace block on unrelated inputs. Changed regions are normalized to removes-before-adds.
- `DiffLine` gains 1-based `a_line`/`b_line` and `no_newline` (git's "no newline at end of file" semantics, no phantom empty final line); `line` is renamed to `text`.
- New `diff_hunks`/`DiffHunk` group changes with context, replacing `filter_diff_context` and its `'...'` sentinel line.
- New `diff_segments` computes intra-line changed-character ranges for paired remove/add lines, with a similarity gate.
- `format_diff` takes hunks and emits unified-diff `@@` headers; colors now go through `print.ts`'s `st` seam (`use_color` removed).
4 changes: 4 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ fuz_util is a **foundational utility library**:
without rebalancing (`fractional_index_between`,
`fractional_indices_between`; base62 alphabet, helper-side jitter,
`FRACTIONAL_INDEX_REGEX` / `_LENGTH_MAX`)
- `diff.ts` - line + intra-line char diffs via greedy Myers (`diff_lines`
with 1-based line numbers and `no_newline`, `diff_hunks` context grouping,
`diff_segments` changed-char ranges, `format_diff`/`generate_diff`
unified-diff text with `@@` headers)

### Async and timing

Expand Down
Loading