Skip to content

Prioritize whole words in inline string diffs - #114

Open
jamilahmadzai wants to merge 1 commit into
concordancejs:mainfrom
jamilahmadzai:codex/word-prioritized-string-diffs
Open

Prioritize whole words in inline string diffs#114
jamilahmadzai wants to merge 1 commit into
concordancejs:mainfrom
jamilahmadzai:codex/word-prioritized-string-diffs

Conversation

@jamilahmadzai

@jamilahmadzai jamilahmadzai commented Jul 18, 2026

Copy link
Copy Markdown

Fixes #29

Summary

  • Tokenize inline string diffs into Unicode-aware word, whitespace, and punctuation atoms before applying fast-diff, keeping short changed words intact.
  • Refine one-for-one replacements over 30 Unicode code points at character level, preserving useful detail for the long-word exception described in the issue.
  • Encode tokens with single UTF-16 code-unit markers so the diff cannot split surrogate pairs, with a character-diff fallback if the marker space is exhausted.
  • Cover short words, long identifiers, non-ASCII words, punctuation, whitespace, multiline output, and inverted/container snapshots.

Validation

  • npx ava test/diff.js — 58 passed on Node.js 24
  • npx --yes --package=node@16 -- node node_modules/ava/cli.js test/diff.js — 58 passed
  • npx --yes --package=node@22 --call "node --version && npm test" — lint passed with 4 existing TODO warnings; all 297 tests passed
  • git diff --check

The repository lint dependency uses the deprecated util.isDate() API, which was removed in Node.js 24. The full gate was therefore run under Node.js 22, a runtime where that legacy dependency still works.


IssueHunt Summary

Referenced issues

This pull request has been submitted to:


@jamilahmadzai
jamilahmadzai marked this pull request as ready for review July 20, 2026 08:58
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.

Inline diffing should prioritize diffing whole words

1 participant