vim-patch:9.1.0740: incorrect internal diff with empty file (#30471)

Problem:  incorrect internal diff with an empty file
Solution: Set pointer to NULL, instead of using an empty line file
          (Yukihiro Nakadaira)

When using internal diff, empty file is read as one empty line file.
So result differs from external diff.

closes: vim/vim#15719

f1694b439b

Co-authored-by: Yukihiro Nakadaira <yukihiro.nakadaira@gmail.com>
This commit is contained in:
zeertzjq
2024-09-23 12:04:07 +08:00
committed by GitHub
parent e83ce331da
commit bfe0acaea1
4 changed files with 46 additions and 4 deletions

View File

@@ -614,6 +614,34 @@ int main(int argc, char **argv)
]])
end)
it('Diff empty and non-empty file', function()
write_file(fname, '', false)
write_file(fname_2, 'foo\nbar\nbaz', false)
reread()
feed(':set diffopt=filler<cr>')
screen:expect([[
{7: }{23:------------------}│{7: }{22:foo }|
{7: }{23:------------------}│{7: }{22:bar }|
{7: }{23:------------------}│{7: }{22:baz }|
{7: }^ │{1:~ }|
{1:~ }│{1:~ }|*10
{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
:set diffopt=filler |
]])
feed(':set diffopt+=internal<cr>')
screen:expect([[
{7: }{23:------------------}│{7: }{22:foo }|
{7: }{23:------------------}│{7: }{22:bar }|
{7: }{23:------------------}│{7: }{22:baz }|
{7: }^ │{1:~ }|
{1:~ }│{1:~ }|*10
{3:<onal-diff-screen-1 }{2:<l-diff-screen-1.2 }|
:set diffopt+=internal |
]])
end)
it('diffopt+=icase', function()
write_file(fname, 'a\nb\ncd\n', false)
write_file(fname_2, 'A\nb\ncDe\n', false)