aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/diff.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-09-27 15:14:39 +0800
committerGitHub <noreply@github.com>2024-09-27 07:14:39 +0000
commit6f2fe8a791646d6d662e89d7eccf6c515ccc9c8c (patch)
treec5c7a73cfc81e422e5e1e5d9f0dc21598559c50c /src/nvim/diff.c
parenta9287dd882e082a17fc7dcf004d3f991ed29001b (diff)
downloadrneovim-6f2fe8a791646d6d662e89d7eccf6c515ccc9c8c.tar.gz
rneovim-6f2fe8a791646d6d662e89d7eccf6c515ccc9c8c.tar.bz2
rneovim-6f2fe8a791646d6d662e89d7eccf6c515ccc9c8c.zip
vim-patch:9.1.0743: diff mode does not handle overlapping diffs correctly (#30532)
Problem: diff mode does not handle overlapping diffs correctly Solution: correct the logic to handle overlapping blocks (Yukihiro Nakadaira) Vim merges overlapped diff blocks and it doesn't work expectedly in some situation. closes: vim/vim#15735 https://github.com/vim/vim/commit/06fe70c183a53ea97cd42ace490d4fb9fd14f042 Co-authored-by: Yukihiro Nakadaira <yukihiro.nakadaira@gmail.com>
Diffstat (limited to 'src/nvim/diff.c')
-rw-r--r--src/nvim/diff.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 0c59b8eb67..05e5bed50c 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -1609,6 +1609,7 @@ static void process_hunk(diff_T **dpp, diff_T **dprevp, int idx_orig, int idx_ne
for (int i = idx_orig; i < idx_new; i++) {
if (curtab->tp_diffbuf[i] != NULL) {
dp->df_lnum[i] -= off;
+ dp->df_count[i] += off;
}
}
dp->df_lnum[idx_new] = hunk->lnum_new;
@@ -1619,11 +1620,7 @@ static void process_hunk(diff_T **dpp, diff_T **dprevp, int idx_orig, int idx_ne
dp->df_count[idx_new] = (linenr_T)hunk->count_new - off;
} else {
// second overlap of new block with existing block
- dp->df_count[idx_new] += (linenr_T)hunk->count_new - (linenr_T)hunk->count_orig
- + dpl->df_lnum[idx_orig] +
- dpl->df_count[idx_orig]
- - (dp->df_lnum[idx_orig] +
- dp->df_count[idx_orig]);
+ dp->df_count[idx_new] += (linenr_T)hunk->count_new;
}
// Adjust the size of the block to include all the lines to the
@@ -1632,11 +1629,8 @@ static void process_hunk(diff_T **dpp, diff_T **dprevp, int idx_orig, int idx_ne
- (dpl->df_lnum[idx_orig] + dpl->df_count[idx_orig]);
if (off < 0) {
- // new change ends in existing block, adjust the end if not
- // done already
- if (*notsetp) {
- dp->df_count[idx_new] += -off;
- }
+ // new change ends in existing block, adjust the end
+ dp->df_count[idx_new] += -off;
off = 0;
}