aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehwang Jerry Jung <tomtomjhj@gmail.com>2021-10-29 11:04:57 +0900
committerGitHub <noreply@github.com>2021-10-28 22:04:57 -0400
commitbb79e05f811968b398b3bedf95c012c888b96e44 (patch)
tree77a7b253afc14585a03c7fbe66a90b967f971fdc
parent4a618b00bc662b976a702bf6205bb132c469a3b8 (diff)
downloadrneovim-bb79e05f811968b398b3bedf95c012c888b96e44.tar.gz
rneovim-bb79e05f811968b398b3bedf95c012c888b96e44.tar.bz2
rneovim-bb79e05f811968b398b3bedf95c012c888b96e44.zip
vim-patch:8.2.3556: filler lines are incorrect for other window in diff mode (#16164)
Problem: Filler lines are incorrect for other window in diff mode after making a change. Solution: Copy filler lines from the current window. (closes vim/vim#8809) https://github.com/vim/vim/commit/841c225b9ef8c5bdf5e02968a0bd62521fff6ca8
-rw-r--r--src/nvim/diff.c21
-rw-r--r--src/nvim/testdir/test_diffmode.vim3
-rw-r--r--test/functional/ui/diff_spec.lua23
3 files changed, 41 insertions, 6 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 80b8920a7f..efbc2fd0db 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -638,7 +638,8 @@ static int diff_check_sanity(tabpage_T *tp, diff_T *dp)
void diff_redraw(bool dofold)
{
win_T *wp_other = NULL;
- bool used_max_fill = false;
+ bool used_max_fill_other = false;
+ bool used_max_fill_curwin = false;
need_diff_redraw = false;
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
@@ -663,16 +664,24 @@ void diff_redraw(bool dofold)
} else if ((n > 0) && (n > wp->w_topfill)) {
wp->w_topfill = n;
if (wp == curwin) {
- used_max_fill = true;
+ used_max_fill_curwin = true;
+ } else if (wp_other != NULL) {
+ used_max_fill_other = 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);
+ if (wp_other != NULL && curwin->w_p_scb) {
+ if (used_max_fill_curwin) {
+ // The current window was set to used the maximum number of filler
+ // lines, may need to reduce them.
+ diff_set_topline(wp_other, curwin);
+ } else if (used_max_fill_other) {
+ // The other window was set to used the maximum number of filler
+ // lines, may need to reduce them.
+ diff_set_topline(curwin, wp_other);
+ }
}
}
diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim
index 32cee7ca56..61da3cbcaa 100644
--- a/src/nvim/testdir/test_diffmode.vim
+++ b/src/nvim/testdir/test_diffmode.vim
@@ -984,6 +984,9 @@ func Test_diff_with_scroll_and_change()
call term_sendkeys(buf, "ax\<Esc>")
call VerifyScreenDump(buf, 'Test_diff_scroll_change_02', {})
+ call term_sendkeys(buf, "\<C-W>lay\<Esc>")
+ call VerifyScreenDump(buf, 'Test_diff_scroll_change_03', {})
+
" clean up
call StopVimInTerminal(buf)
call delete('Xtest_scroll_change')
diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua
index df750a1a68..13949b0756 100644
--- a/test/functional/ui/diff_spec.lua
+++ b/test/functional/ui/diff_spec.lua
@@ -1196,4 +1196,27 @@ it('Align the filler lines when changing text in diff mode', function()
{8:[No Name] [+] }{3:[No Name] [+] }|
|
]]}
+ feed('<C-W>lay<Esc>')
+ screen:expect{grid=[[
+ {1: }{2:-----------------}{3:│}{1: }{4:6 }|
+ {1: }{2:-----------------}{3:│}{1: }{4:7 }|
+ {1: }{2:-----------------}{3:│}{1: }{4:8 }|
+ {1: }9 {3:│}{1: }9 |
+ {1: }10 {3:│}{1: }10 |
+ {1: }11 {3:│}{1: }11 |
+ {1: }12 {3:│}{1: }12 |
+ {1: }13 {3:│}{1: }13 |
+ {1: }14 {3:│}{1: }14 |
+ {1: }{5:15}{6:x}{5: }{3:│}{1: }{5:15}{6:^y}{5: }|
+ {7:~ }{3:│}{7:~ }|
+ {7:~ }{3:│}{7:~ }|
+ {7:~ }{3:│}{7:~ }|
+ {7:~ }{3:│}{7:~ }|
+ {7:~ }{3:│}{7:~ }|
+ {7:~ }{3:│}{7:~ }|
+ {7:~ }{3:│}{7:~ }|
+ {7:~ }{3:│}{7:~ }|
+ {3:[No Name] [+] }{8:[No Name] [+] }|
+ |
+ ]]}
end)