# HG changeset patch # User Bram Moolenaar # Date 1656071104 -7200 # Node ID 281509f1417ba92e233721f42f3396f897b3281f # Parent d314efe6447a9c5694d4576114f8549aadee56a1 patch 8.2.5155: in diff mode windows may get out of sync Commit: https://github.com/vim/vim/commit/a315ce1f326b836167ca8b1037dafd93eb8d4d4e Author: Bram Moolenaar Date: Fri Jun 24 12:38:57 2022 +0100 patch 8.2.5155: in diff mode windows may get out of sync Problem: In diff mode windows may get out of sync. (Gary Johnson) Solution: Avoid that the other window scrolls for 'cursorbind'. diff --git a/src/move.c b/src/move.c --- a/src/move.c +++ b/src/move.c @@ -2952,7 +2952,12 @@ do_check_cursorbind(void) restart_edit_save = restart_edit; restart_edit = TRUE; check_cursor(); - validate_cursor(); + + // Avoid a scroll here for the cursor position, 'scrollbind' is + // more important. + if (!curwin->w_p_scb) + validate_cursor(); + restart_edit = restart_edit_save; // Correct cursor for multi-byte character. if (has_mbyte) diff --git a/src/testdir/dumps/Test_diff_scroll_1.dump b/src/testdir/dumps/Test_diff_scroll_1.dump new file mode 100644 --- /dev/null +++ b/src/testdir/dumps/Test_diff_scroll_1.dump @@ -0,0 +1,12 @@ +| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |1| @28||+1&&| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |1| @28 +| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |2| @28||+1&&| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |2| @28 +| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |3| @28||+1&&| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |3| @28 +| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |4| @28||+1&&| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |4| @28 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@34||+1&&| +0#0000e05#a8a8a8255@1> +0#0000000#ffffff0@34 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|L+0#0000000#5fd7ff255|o|r|e|m| @29 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|i+0#0000000#5fd7ff255|p|s|u|m| @29 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|d+0#0000000#5fd7ff255|o|l|o|r| @29 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|s+0#0000000#5fd7ff255|i|t| @31 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|a+0#0000000#5fd7ff255|m|e|t|,| @29 +|X+1&#ffffff0|l|e|f|t| @13|5|,|0|-|1| @9|T|o|p| |X+3&&|r|i|g|h|t| @12|5|,|0|-|1| @9|T|o|p +|"+0&&|X|r|i|g|h|t|"| |3@1|L|,| |2|6|3|B| @56 diff --git a/src/testdir/dumps/Test_diff_scroll_2.dump b/src/testdir/dumps/Test_diff_scroll_2.dump new file mode 100644 --- /dev/null +++ b/src/testdir/dumps/Test_diff_scroll_2.dump @@ -0,0 +1,12 @@ +| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |1| @28||+1&&| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |1| @28 +| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |2| @28||+1&&| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |2| @28 +| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |3| @28||+1&&| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |3| @28 +| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |4| @28||+1&&| +0#0000e05#a8a8a8255@1|l+0#0000000#ffffff0|i|n|e| |4| @28 +| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@34||+1&&| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@34 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1>L+0#0000000#5fd7ff255|o|r|e|m| @29 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|i+0#0000000#5fd7ff255|p|s|u|m| @29 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|d+0#0000000#5fd7ff255|o|l|o|r| @29 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|s+0#0000000#5fd7ff255|i|t| @31 +| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@34||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|a+0#0000000#5fd7ff255|m|e|t|,| @29 +|X+1&#ffffff0|l|e|f|t| @13|6|,|1| @11|T|o|p| |X+3&&|r|i|g|h|t| @12|6|,|1| @11|T|o|p +|"+0&&|X|r|i|g|h|t|"| |3@1|L|,| |2|6|3|B| @56 diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim --- a/src/testdir/test_diffmode.vim +++ b/src/testdir/test_diffmode.vim @@ -1535,4 +1535,73 @@ func Test_diff_foldinvert() set scrollbind& endfunc +" This was scrolling for 'cursorbind' but 'scrollbind' is more important +func Test_diff_scroll() + CheckScreendump + + let left =<< trim END + line 1 + line 2 + line 3 + line 4 + + // Common block + // one + // containing + // four lines + + // Common block + // two + // containing + // four lines + END + call writefile(left, 'Xleft') + let right =<< trim END + line 1 + line 2 + line 3 + line 4 + + Lorem + ipsum + dolor + sit + amet, + consectetur + adipiscing + elit. + Etiam + luctus + lectus + sodales, + dictum + + // Common block + // one + // containing + // four lines + + Vestibulum + tincidunt + aliquet + nulla. + + // Common block + // two + // containing + // four lines + END + call writefile(right, 'Xright') + let buf = RunVimInTerminal('-d Xleft Xright', {'rows': 12}) + call term_sendkeys(buf, "\\jjjj") + call VerifyScreenDump(buf, 'Test_diff_scroll_1', {}) + call term_sendkeys(buf, "j") + call VerifyScreenDump(buf, 'Test_diff_scroll_2', {}) + + call StopVimInTerminal(buf) + call delete('Xleft') + call delete('Xright') +endfunc + + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -736,6 +736,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 5155, +/**/ 5154, /**/ 5153,