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

@@ -736,6 +736,12 @@ static void clear_diffout(diffout_T *dout)
/// @return FAIL for failure.
static int diff_write_buffer(buf_T *buf, mmfile_t *m, linenr_T start, linenr_T end)
{
if (buf->b_ml.ml_flags & ML_EMPTY) {
m->ptr = NULL;
m->size = 0;
return OK;
}
size_t len = 0;
if (end < 0) {