mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-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'.
a315ce1f32
This commit is contained in:
@@ -2271,7 +2271,13 @@ void do_check_cursorbind(void)
|
|||||||
int restart_edit_save = restart_edit;
|
int restart_edit_save = restart_edit;
|
||||||
restart_edit = true;
|
restart_edit = true;
|
||||||
check_cursor();
|
check_cursor();
|
||||||
|
|
||||||
|
// Avoid a scroll here for the cursor position, 'scrollbind' is
|
||||||
|
// more important.
|
||||||
|
if (!curwin->w_p_scb) {
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
|
}
|
||||||
|
|
||||||
restart_edit = restart_edit_save;
|
restart_edit = restart_edit_save;
|
||||||
}
|
}
|
||||||
// Correct cursor for multi-byte character.
|
// Correct cursor for multi-byte character.
|
||||||
|
@@ -1378,4 +1378,73 @@ func Test_diff_foldinvert()
|
|||||||
set scrollbind&
|
set scrollbind&
|
||||||
endfunc
|
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, "\<C-W>\<C-W>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
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -6,6 +6,7 @@ local clear = helpers.clear
|
|||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local insert = helpers.insert
|
local insert = helpers.insert
|
||||||
local write_file = helpers.write_file
|
local write_file = helpers.write_file
|
||||||
|
local dedent = helpers.dedent
|
||||||
local exec = helpers.exec
|
local exec = helpers.exec
|
||||||
|
|
||||||
describe('Diff mode screen', function()
|
describe('Diff mode screen', function()
|
||||||
@@ -985,6 +986,93 @@ int main(int argc, char **argv)
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- oldtest: Test_diff_scroll()
|
||||||
|
-- This was scrolling for 'cursorbind' but 'scrollbind' is more important
|
||||||
|
it('scrolling works correctly vim-patch:8.2.5155', function()
|
||||||
|
screen:try_resize(40, 12)
|
||||||
|
write_file(fname, dedent([[
|
||||||
|
line 1
|
||||||
|
line 2
|
||||||
|
line 3
|
||||||
|
line 4
|
||||||
|
|
||||||
|
// Common block
|
||||||
|
// one
|
||||||
|
// containing
|
||||||
|
// four lines
|
||||||
|
|
||||||
|
// Common block
|
||||||
|
// two
|
||||||
|
// containing
|
||||||
|
// four lines]]), false)
|
||||||
|
write_file(fname_2, dedent([[
|
||||||
|
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]]), false)
|
||||||
|
reread()
|
||||||
|
|
||||||
|
feed('<C-W><C-W>jjjj')
|
||||||
|
screen:expect([[
|
||||||
|
{1: }line 1 │{1: }line 1 |
|
||||||
|
{1: }line 2 │{1: }line 2 |
|
||||||
|
{1: }line 3 │{1: }line 3 |
|
||||||
|
{1: }line 4 │{1: }line 4 |
|
||||||
|
{1: } │{1: }^ |
|
||||||
|
{1: }{2:-----------------}│{1: }{4:Lorem }|
|
||||||
|
{1: }{2:-----------------}│{1: }{4:ipsum }|
|
||||||
|
{1: }{2:-----------------}│{1: }{4:dolor }|
|
||||||
|
{1: }{2:-----------------}│{1: }{4:sit }|
|
||||||
|
{1: }{2:-----------------}│{1: }{4:amet, }|
|
||||||
|
{3:<nal-diff-screen-1 }{7:<al-diff-screen-1.2 }|
|
||||||
|
:e |
|
||||||
|
]])
|
||||||
|
feed('j')
|
||||||
|
screen:expect([[
|
||||||
|
{1: }line 1 │{1: }line 1 |
|
||||||
|
{1: }line 2 │{1: }line 2 |
|
||||||
|
{1: }line 3 │{1: }line 3 |
|
||||||
|
{1: }line 4 │{1: }line 4 |
|
||||||
|
{1: } │{1: } |
|
||||||
|
{1: }{2:-----------------}│{1: }{4:^Lorem }|
|
||||||
|
{1: }{2:-----------------}│{1: }{4:ipsum }|
|
||||||
|
{1: }{2:-----------------}│{1: }{4:dolor }|
|
||||||
|
{1: }{2:-----------------}│{1: }{4:sit }|
|
||||||
|
{1: }{2:-----------------}│{1: }{4:amet, }|
|
||||||
|
{3:<nal-diff-screen-1 }{7:<al-diff-screen-1.2 }|
|
||||||
|
:e |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('win_update redraws lines properly', function()
|
it('win_update redraws lines properly', function()
|
||||||
@@ -1227,6 +1315,7 @@ it('Align the filler lines when changing text in diff mode', function()
|
|||||||
]]}
|
]]}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- oldtest: Test_diff_binary()
|
||||||
it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', function()
|
it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', function()
|
||||||
clear()
|
clear()
|
||||||
local screen = Screen.new(40, 20)
|
local screen = Screen.new(40, 20)
|
||||||
|
Reference in New Issue
Block a user