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.
This commit is contained in:
parent
2d72963f8f
commit
93f6627dd2
1 changed files with 6 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue