diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-04-08 10:45:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 10:45:42 +0800 |
commit | 2c7dc648ca796786b4847771c1df71dea20a1774 (patch) | |
tree | 662b1aa12c7d53d0c200a86397a89eb77284a9c8 /src/nvim/diff.c | |
parent | 356baae80ad42e8a13d650675a0e56e931f08541 (diff) | |
download | rneovim-2c7dc648ca796786b4847771c1df71dea20a1774.tar.gz rneovim-2c7dc648ca796786b4847771c1df71dea20a1774.tar.bz2 rneovim-2c7dc648ca796786b4847771c1df71dea20a1774.zip |
vim-patch:8.2.3925: diff mode confused by NUL bytes (#18033)
Problem: Diff mode confused by NUL bytes.
Solution: Handle NUL bytes differently. (Christian Brabandt, closes vim/vim#9421,
closes vim/vim#9418)
https://github.com/vim/vim/commit/06f6095623cfcc72da08748c058d13b465652fd4
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r-- | src/nvim/diff.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index a6bbe40999..0b55fb877c 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -743,11 +743,16 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) { for (char_u *s = ml_get_buf(buf, lnum, false); *s != NUL;) { if (diff_flags & DIFF_ICASE) { + int c; char_u cbuf[MB_MAXBYTES + 1]; - // xdiff doesn't support ignoring case, fold-case the text. - int c = utf_ptr2char(s); - c = utf_fold(c); + if (*s == NL) { + c = NUL; + } else { + // xdiff doesn't support ignoring case, fold-case the text. + c = utf_ptr2char(s); + c = utf_fold(c); + } const int orig_len = utfc_ptr2len(s); if (utf_char2bytes(c, cbuf) != orig_len) { // TODO(Bram): handle byte length difference @@ -759,7 +764,8 @@ static int diff_write_buffer(buf_T *buf, diffin_T *din) s += orig_len; len += orig_len; } else { - ptr[len++] = *s++; + ptr[len++] = *s == NL ? NUL : *s; + s++; } } ptr[len++] = NL; |