Skip to content

Releases: cvlmtg/inline-diff.nvim

v3.0.0

Choose a tag to compare

@cvlmtg cvlmtg released this 20 Mar 23:12

Breaking changes

None. Public API (setup, enable, disable, toggle, commands) is unchanged.

Performance

Line-level diff now uses Neovim's built-in vim.diff() (C xdiff library) instead of the pure-Lua Myers implementation. Benchmarks on an M4 Pro, Neovim 0.11.6:

Dataset Before (Myers) After (xdiff)
small/scattered ~200 lines 0.2 ms 0.2 ms
small/mixed ~400 lines 5 ms 3 ms
large/scattered ~2000 lines 8 ms 1.3 ms
large/mixed ~4000 lines ~180 ms 34 ms

The async thread machinery (vim.uv.new_thread, _worker.lua, JSON encode/decode round-trip) is removed — vim.diff is synchronous C code fast enough for all file sizes.

Internal

  • Deleted lua/inline-diff/_worker.lua
  • compute_hunks is now synchronous (callback still called for API compatibility)
  • _myers_matched is kept for word-level (sub-line) diffing
  • Added bench/ suite for reproducing the measurements: nvim --headless --clean -c "set rtp+=." -c "luafile bench/run.lua"

v2.3.0

Choose a tag to compare

@cvlmtg cvlmtg released this 14 Mar 21:27

Fixed

  • Word-level diff no longer splits multi-byte UTF-8 characters (CJK, accented letters, emoji) across token boundaries. Previously each byte of a multi-byte character was treated as a separate token, which could produce nvim_buf_set_extmark calls with byte offsets landing mid-codepoint, causing garbled highlight rendering.

Tests

74 tests (up from 69); added _tokenize unit tests and multi-byte word-diff coverage

v2.2.0

Choose a tag to compare

@cvlmtg cvlmtg released this 14 Mar 20:54

Documentation

  • Improved README with clearer setup and usage instructions
  • Updated demo GIF

v2.1.0

Choose a tag to compare

@cvlmtg cvlmtg released this 14 Mar 14:29

Performance

  • Myers O(ND) word diff — word-level diff now uses the same Myers algorithm as line diff, replacing the O(m×n) LCS
  • Hunk cache — skip extmark clear+rebuild when hunks are unchanged between refreshes (the common case while typing within an existing change)
  • Raised sync threshold to 500 lines — files under 500 total lines diff synchronously, avoiding thread serialization overhead for the vast majority of real-world files
  • decode_lines allocation fix — worker no longer allocates a full copy of the content string to split lines

Fixed

  • prev_hunks cache correctly invalidated when switching refs, preventing a blank buffer after render.clear()

Tests

69 tests (up from 60); added _hunks_equal unit tests and ref-switch invalidation coverage

v2.0.0

Choose a tag to compare

@cvlmtg cvlmtg released this 13 Mar 17:15

Fixed

  • Windows: git show path spec now uses forward slashes; backslashes in relpath caused git to report "path exists on disk but not in HEAD"
  • Windows: git show output with CRLF line endings no longer leaves trailing \r on every old line, which caused all lines to compare unequal
  • Thread worker: if require("inline-diff._worker") fails in the background thread (e.g. due to package.path resolution differences), the diff now falls back to synchronous computation on the main thread instead of silently producing no output

Performance

  • Diff computation runs off the main thread via vim.uv.new_thread, keeping the UI responsive on large files

v1.0.0

Choose a tag to compare

@cvlmtg cvlmtg released this 07 Mar 16:45

What's new

Added

  • [ref] argument on all commands and the Lua API — diff against any git ref per invocation without changing the default (HEAD~1, a branch, a SHA, …)
  • staged ref: diff against the git index (what you've git add-ed); falls back to HEAD automatically when the file has no staged content

Fixed

  • Auto-scroll now correctly reveals all bottom virtual lines when the last buffer line wraps to more than one visual row
  • Auto-scroll no longer crashes when topline == buf_line_count

Performance

  • Removed redundant O(m+n) line-copy in _diff_lines
  • LCS dp-table initialization reduced from O(m×n) to O(m+n) by only pre-filling boundary rows/cols
  • compute_hunks now delivers results synchronously, saving one event-loop round-trip per keystroke

Tests

  • Expanded test suite to 56 tests; added dedicated scroll_spec.lua

See CHANGELOG.md for the full history.