diff options
author | Anatolii Sakhnik <sakhnik@gmail.com> | 2018-12-09 20:13:34 +0200 |
---|---|---|
committer | Anatolii Sakhnik <sakhnik@gmail.com> | 2018-12-09 22:19:41 +0200 |
commit | 89eba72792fb9e36ede7e9d58f5673ebfd553178 (patch) | |
tree | a745bec43165aff02d89bde7e4aee9af939127bc /src/nvim/diff.c | |
parent | 8f20c22e10c35075afd97bf6af50fb6d9a2dc710 (diff) | |
download | rneovim-89eba72792fb9e36ede7e9d58f5673ebfd553178.tar.gz rneovim-89eba72792fb9e36ede7e9d58f5673ebfd553178.tar.bz2 rneovim-89eba72792fb9e36ede7e9d58f5673ebfd553178.zip |
vim-patch:8.1.0502: internal diff fails when diffing a context diff
Problem: Internal diff fails when diffing a context diff. (Hirohito Higashi)
Solution: Only use callback calls with one line. (closes #3581)
https://github.com/vim/vim/commit/f080d70a82f3a4477f346d9efcdfaec1bc1e1d58
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r-- | src/nvim/diff.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 2bb73f63ba..6dbebd5e29 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -3103,20 +3103,22 @@ static int parse_diff_unified(char_u *line, static int xdiff_out(void *priv, mmbuffer_t *mb, int nbuf) { diffout_T *dout = (diffout_T *)priv; - int i; char_u *p; - for (i = 0; i < nbuf; i++) { - // We are only interested in the header lines, skip text lines. - if (STRNCMP(mb[i].ptr, "@@ ", 3) != 0) { - continue; - } - ga_grow(&dout->dout_ga, 1); - p = vim_strnsave((char_u *)mb[i].ptr, mb[i].size); - if (p == NULL) { - return -1; - } - ((char_u **)dout->dout_ga.ga_data)[dout->dout_ga.ga_len++] = p; + // The header line always comes by itself, text lines in at least two + // parts. We drop the text part. + if (nbuf > 1) { + return 0; } + + // sanity check + if (STRNCMP(mb[0].ptr, "@@ ", 3) != 0) { + return 0; + } + + ga_grow(&dout->dout_ga, 1); + + p = vim_strnsave((char_u *)mb[0].ptr, mb[0].size); + ((char_u **)dout->dout_ga.ga_data)[dout->dout_ga.ga_len++] = p; return 0; } |