mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 14:58:18 +00:00
fix(diff): use mmfile_t in linematch
Problem:
Linematch used to use strchr to navigate a string, however strchr does
not supoprt embedded NULs.
Solution:
Use `mmfile_t` instead of `char *` in linematch and introduce `strnchr()`.
Also remove heap allocations from `matching_char_iwhite()`
Fixes: #30505
(cherry picked from commit c65646c247
)
This commit is contained in:
@@ -174,4 +174,13 @@ describe('xdiff bindings', function()
|
||||
pcall_err(exec_lua, [[vim.diff('a', 'b', { on_hunk = true })]])
|
||||
)
|
||||
end)
|
||||
|
||||
it('can handle strings with embedded NUL characters (GitHub #30305)', function()
|
||||
eq(
|
||||
{ { 0, 0, 1, 1 }, { 1, 0, 3, 2 } },
|
||||
exec_lua([[
|
||||
return vim.diff('\n', '\0\n\n\nb', { linematch = true, result_type = 'indices' })
|
||||
]])
|
||||
)
|
||||
end)
|
||||
end)
|
||||
|
Reference in New Issue
Block a user