From 93f6627dd2b6761e0f7959945d85b3492d845926 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sat, 7 Feb 2026 00:50:08 -0500 Subject: [PATCH] fix(diff): strip linematch from char-level diff Problem: parse_diffopt() passes linematch from diffopt to byte-level vim.diff() in char_diff_pair, where each "line" is a single byte. linematch is meaningless at this granularity. Solution: copy diff_opts without linematch before passing to byte_diff in char_diff_pair. linematch remains in effect for the line-level diff in diff_group_native where it belongs. --- lua/diffs/diff.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/diffs/diff.lua b/lua/diffs/diff.lua index 5f10f9a..edf0275 100644 --- a/lua/diffs/diff.lua +++ b/lua/diffs/diff.lua @@ -137,7 +137,12 @@ local function char_diff_pair(old_line, new_line, del_idx, add_idx, diff_opts) local old_text = table.concat(old_bytes, '\n') .. '\n' local new_text = table.concat(new_bytes, '\n') .. '\n' - local char_hunks = byte_diff(old_text, new_text, diff_opts) + local char_opts = diff_opts + if diff_opts and diff_opts.linematch then + char_opts = { algorithm = diff_opts.algorithm } + end + + local char_hunks = byte_diff(old_text, new_text, char_opts) for _, ch in ipairs(char_hunks) do if ch.old_count > 0 then