mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 15:21:47 +00:00
vim-patch:8.2.3394: filler lines are wrong when changing text in diff mode (#15547)
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 vim/vim#8809)
04626c243c
This commit is contained in:

committed by
GitHub

parent
51a98aa0c2
commit
de406f651c
@@ -639,12 +639,18 @@ static int diff_check_sanity(tabpage_T *tp, diff_T *dp)
|
|||||||
/// @param dofold Also recompute the folds
|
/// @param dofold Also recompute the folds
|
||||||
void diff_redraw(bool dofold)
|
void diff_redraw(bool dofold)
|
||||||
{
|
{
|
||||||
|
win_T *wp_other = NULL;
|
||||||
|
bool used_max_fill = false;
|
||||||
|
|
||||||
need_diff_redraw = false;
|
need_diff_redraw = false;
|
||||||
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
|
||||||
if (!wp->w_p_diff) {
|
if (!wp->w_p_diff) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
redraw_later(wp, SOME_VALID);
|
redraw_later(wp, SOME_VALID);
|
||||||
|
if (wp != curwin) {
|
||||||
|
wp_other = wp;
|
||||||
|
}
|
||||||
if (dofold && foldmethodIsDiff(wp)) {
|
if (dofold && foldmethodIsDiff(wp)) {
|
||||||
foldUpdateAll(wp);
|
foldUpdateAll(wp);
|
||||||
}
|
}
|
||||||
@@ -658,10 +664,18 @@ void diff_redraw(bool dofold)
|
|||||||
wp->w_topfill = (n < 0 ? 0 : n);
|
wp->w_topfill = (n < 0 ? 0 : n);
|
||||||
} else if ((n > 0) && (n > wp->w_topfill)) {
|
} else if ((n > 0) && (n > wp->w_topfill)) {
|
||||||
wp->w_topfill = n;
|
wp->w_topfill = n;
|
||||||
|
if (wp == curwin) {
|
||||||
|
used_max_fill = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
check_topfill(wp, false);
|
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 clear_diffin(diffin_T *din)
|
static void clear_diffin(diffin_T *din)
|
||||||
|
@@ -453,13 +453,18 @@ void changed_window_setting_win(win_T *wp)
|
|||||||
*/
|
*/
|
||||||
void set_topline(win_T *wp, linenr_T lnum)
|
void set_topline(win_T *wp, linenr_T lnum)
|
||||||
{
|
{
|
||||||
/* go to first of folded lines */
|
linenr_T prev_topline = wp->w_topline;
|
||||||
|
|
||||||
|
// go to first of folded lines
|
||||||
(void)hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
|
(void)hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
|
||||||
/* Approximate the value of w_botline */
|
// Approximate the value of w_botline
|
||||||
wp->w_botline += lnum - wp->w_topline;
|
wp->w_botline += lnum - wp->w_topline;
|
||||||
wp->w_topline = lnum;
|
wp->w_topline = lnum;
|
||||||
wp->w_topline_was_set = true;
|
wp->w_topline_was_set = true;
|
||||||
wp->w_topfill = 0;
|
if (lnum != prev_topline) {
|
||||||
|
// Keep the filler lines when the topline didn't change.
|
||||||
|
wp->w_topfill = 0;
|
||||||
|
}
|
||||||
wp->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_TOPLINE);
|
wp->w_valid &= ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_TOPLINE);
|
||||||
// Don't set VALID_TOPLINE here, 'scrolloff' needs to be checked.
|
// Don't set VALID_TOPLINE here, 'scrolloff' needs to be checked.
|
||||||
redraw_later(wp, VALID);
|
redraw_later(wp, VALID);
|
||||||
|
@@ -965,6 +965,30 @@ func Test_diff_screen()
|
|||||||
call delete('XdiffSetup')
|
call delete('XdiffSetup')
|
||||||
endfunc
|
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\<C-E>"
|
||||||
|
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\<Esc>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_diff_scroll_change_02', {})
|
||||||
|
|
||||||
|
" clean up
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('Xtest_scroll_change')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_diff_with_cursorline()
|
func Test_diff_with_cursorline()
|
||||||
CheckScreendump
|
CheckScreendump
|
||||||
|
|
||||||
|
@@ -1128,3 +1128,72 @@ it('diff updates line numbers below filler lines', function()
|
|||||||
signcolumn=auto |
|
signcolumn=auto |
|
||||||
]]}
|
]]}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('Align the filler lines when changing text in diff mode', function()
|
||||||
|
clear()
|
||||||
|
local screen = Screen.new(40, 20)
|
||||||
|
screen:attach()
|
||||||
|
screen:set_default_attr_ids({
|
||||||
|
[1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray};
|
||||||
|
[2] = {background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1, bold = true};
|
||||||
|
[3] = {reverse = true};
|
||||||
|
[4] = {background = Screen.colors.LightBlue};
|
||||||
|
[5] = {background = Screen.colors.LightMagenta};
|
||||||
|
[6] = {background = Screen.colors.Red, bold = true};
|
||||||
|
[7] = {foreground = Screen.colors.Blue1, bold = true};
|
||||||
|
[8] = {reverse = true, bold = true};
|
||||||
|
})
|
||||||
|
source([[
|
||||||
|
call setline(1, range(1, 15))
|
||||||
|
vnew
|
||||||
|
call setline(1, range(9, 15))
|
||||||
|
windo diffthis
|
||||||
|
wincmd h
|
||||||
|
exe "normal Gl5\<C-E>"
|
||||||
|
]])
|
||||||
|
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:- }1^5 {3:│}{1:- }15 |
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{8:[No Name] [+] }{3:[No Name] [+] }|
|
||||||
|
|
|
||||||
|
]]}
|
||||||
|
feed('ax<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 }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{7:~ }{3:│}{7:~ }|
|
||||||
|
{8:[No Name] [+] }{3:[No Name] [+] }|
|
||||||
|
|
|
||||||
|
]]}
|
||||||
|
end)
|
||||||
|
Reference in New Issue
Block a user