0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 9.1.0740: incorrect internal diff with empty file

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: #15719

Signed-off-by: Yukihiro Nakadaira <yukihiro.nakadaira@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Yukihiro Nakadaira
2024-09-22 11:26:13 +02:00
committed by Christian Brabandt
parent a6de28755e
commit f1694b439b
5 changed files with 58 additions and 1 deletions

View File

@@ -760,6 +760,13 @@ diff_write_buffer(buf_T *buf, diffin_T *din)
long len = 0;
char_u *ptr;
if (buf->b_ml.ml_flags & ML_EMPTY)
{
din->din_mmfile.ptr = NULL;
din->din_mmfile.size = 0;
return OK;
}
// xdiff requires one big block of memory with all the text.
for (lnum = 1; lnum <= buf->b_ml.ml_line_count; ++lnum)
len += ml_get_buf_len(buf, lnum) + 1;