To: vim_dev@googlegroups.com Subject: Patch 8.2.3394 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3394 Problem: Filler lines are wrong when changing text in diff mode. Solution: Don't change the filler lines on every change. Check scrollbinding when updating the filler lines. (closes #8809) Files: src/move.c, src/diff.c, src/testdir/test_diffmode.vim, src/testdir/dumps/Test_diff_scroll_change_01.dump, src/testdir/dumps/Test_diff_scroll_change_02.dump *** ../vim-8.2.3393/src/move.c 2021-07-27 22:00:39.749712387 +0200 --- src/move.c 2021-09-01 15:59:54.161330465 +0200 *************** *** 535,540 **** --- 535,544 ---- void set_topline(win_T *wp, linenr_T lnum) { + #ifdef FEAT_DIFF + linenr_T prev_topline = wp->w_topline; + #endif + #ifdef FEAT_FOLDING // go to first of folded lines (void)hasFoldingWin(wp, lnum, &lnum, NULL, TRUE, NULL); *************** *** 546,552 **** wp->w_topline = lnum; wp->w_topline_was_set = TRUE; #ifdef FEAT_DIFF ! wp->w_topfill = 0; #endif wp->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_TOPLINE); // Don't set VALID_TOPLINE here, 'scrolloff' needs to be checked. --- 550,558 ---- wp->w_topline = lnum; wp->w_topline_was_set = TRUE; #ifdef FEAT_DIFF ! if (lnum != prev_topline) ! // Keep the filler lines when the topline didn't change. ! wp->w_topfill = 0; #endif wp->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_TOPLINE); // Don't set VALID_TOPLINE here, 'scrolloff' needs to be checked. *** ../vim-8.2.3393/src/diff.c 2021-08-31 20:46:34.872123774 +0200 --- src/diff.c 2021-09-01 15:58:49.333460970 +0200 *************** *** 655,660 **** --- 655,662 ---- int dofold) // also recompute the folds { win_T *wp; + win_T *wp_other = NULL; + int used_max_fill = FALSE; int n; need_diff_redraw = FALSE; *************** *** 662,667 **** --- 664,671 ---- if (wp->w_p_diff) { redraw_win_later(wp, SOME_VALID); + if (wp != curwin) + wp_other = wp; #ifdef FEAT_FOLDING if (dofold && foldmethodIsDiff(wp)) foldUpdateAll(wp); *************** *** 674,683 **** --- 678,696 ---- if (wp->w_topfill > n) wp->w_topfill = (n < 0 ? 0 : n); else if (n > 0 && n > wp->w_topfill) + { wp->w_topfill = n; + if (wp == curwin) + used_max_fill = TRUE; + } check_topfill(wp, FALSE); } } + + if (wp_other != NULL && used_max_fill && curwin->w_p_scb) + // The current window was set to used the maximum number of filler + // lines, may need to reduce them. + diff_set_topline(wp_other, curwin); } static void *** ../vim-8.2.3393/src/testdir/test_diffmode.vim 2021-08-05 17:56:03.212718211 +0200 --- src/testdir/test_diffmode.vim 2021-09-01 15:56:05.685788560 +0200 *************** *** 993,998 **** --- 993,1022 ---- call delete('XdiffSetup') endfunc + func Test_diff_with_scroll_and_change() + CheckScreendump + + let lines =<< trim END + call setline(1, range(1, 15)) + vnew + call setline(1, range(9, 15)) + windo diffthis + wincmd h + exe "normal Gl5\" + END + call writefile(lines, 'Xtest_scroll_change') + let buf = RunVimInTerminal('-S Xtest_scroll_change', {}) + + call VerifyScreenDump(buf, 'Test_diff_scroll_change_01', {}) + + call term_sendkeys(buf, "ax\") + call VerifyScreenDump(buf, 'Test_diff_scroll_change_02', {}) + + " clean up + call StopVimInTerminal(buf) + call delete('Xtest_scroll_change') + endfunc + func Test_diff_with_cursorline() CheckScreendump *** ../vim-8.2.3393/src/testdir/dumps/Test_diff_scroll_change_01.dump 2021-09-01 16:01:07.581182210 +0200 --- src/testdir/dumps/Test_diff_scroll_change_01.dump 2021-09-01 15:56:16.721766572 +0200 *************** *** 0 **** --- 1,20 ---- + | +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|6+0#0000000#5fd7ff255| @33 + | +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|7+0#0000000#5fd7ff255| @33 + | +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|8+0#0000000#5fd7ff255| @33 + | +0#0000e05#a8a8a8255@1|9+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|9+0#0000000#ffffff0| @33 + | +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|0| @32||+1&&| +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|0| @32 + | +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0@1| @32||+1&&| +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0@1| @32 + | +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|2| @32||+1&&| +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|2| @32 + | +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|3| @32||+1&&| +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|3| @32 + | +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|4| @32||+1&&| +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|4| @32 + |-+0#0000e05#a8a8a8255| |1+0#0000000#ffffff0>5| @32||+1&&|-+0#0000e05#a8a8a8255| |1+0#0000000#ffffff0|5| @32 + |~+0#4040ff13&| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @5|7|,|2| @11|A|l@1| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @5|1|5|,|2| @10|B|o|t + | +0&&@74 *** ../vim-8.2.3393/src/testdir/dumps/Test_diff_scroll_change_02.dump 2021-09-01 16:01:07.585182204 +0200 --- src/testdir/dumps/Test_diff_scroll_change_02.dump 2021-09-01 15:56:17.789764443 +0200 *************** *** 0 **** --- 1,20 ---- + | +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|6+0#0000000#5fd7ff255| @33 + | +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|7+0#0000000#5fd7ff255| @33 + | +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|8+0#0000000#5fd7ff255| @33 + | +0#0000e05#a8a8a8255@1|9+0#0000000#ffffff0| @33||+1&&| +0#0000e05#a8a8a8255@1|9+0#0000000#ffffff0| @33 + | +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|0| @32||+1&&| +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|0| @32 + | +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0@1| @32||+1&&| +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0@1| @32 + | +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|2| @32||+1&&| +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|2| @32 + | +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|3| @32||+1&&| +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|3| @32 + | +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|4| @32||+1&&| +0#0000e05#a8a8a8255@1|1+0#0000000#ffffff0|4| @32 + | +0#0000e05#a8a8a8255@1|1+0#0000000#ffd7ff255|5>x+2&#ff404010| +0&#ffd7ff255@31||+1&#ffffff0| +0#0000e05#a8a8a8255@1|1+0#0000000#ffd7ff255|5| @32 + |~+0#4040ff13#ffffff0| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |~| @35||+1#0000000&|~+0#4040ff13&| @35 + |[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @5|7|,|3| @11|A|l@1| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @5|1|5|,|3| @10|B|o|t + | +0&&@74 *** ../vim-8.2.3393/src/version.c 2021-09-01 14:31:47.631129937 +0200 --- src/version.c 2021-09-01 16:00:37.329243341 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3394, /**/ -- Managers are like cats in a litter box. They instinctively shuffle things around to conceal what they've done. (Scott Adams - The Dilbert principle) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///