vim-patch:9.1.0822: topline might be changed in diff mode unexpectedly (#30988)

Problem:  topline might be changed in diff mode unexpectedly
          (Jaehwang Jung)
Solution: do not re-calculate topline, when using line() func
          in diff mode.

fixes: vim/vim#15812
closes: vim/vim#15950

05a40e07c2

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-10-30 09:05:11 +08:00
committed by GitHub
parent ff93cccbc1
commit 05d9e6a9e8
3 changed files with 141 additions and 0 deletions

View File

@@ -2007,4 +2007,31 @@ func Test_diff_overlapped_diff_blocks_will_be_merged()
call WriteDiffFiles3(buf, ["a", "b", "c"], ["a", "x", "c"], ["a", "b", "y", "c"])
call VerifyBoth(buf, "Test_diff_overlapped_3.37", "")
call StopVimInTerminal(buf)
endfunc
" switching windows in diff mode caused an unneccessary scroll
func Test_diff_topline_noscroll()
CheckScreendump
let content =<< trim END
call setline(1, range(1,60))
vnew
call setline(1, range(1,10) + range(50,60))
windo diffthis
norm! G
exe "norm! 30\<C-y>"
END
call writefile(content, 'Xcontent', 'D')
let buf = RunVimInTerminal('-S Xcontent', {'rows': 20})
call VerifyScreenDump(buf, 'Test_diff_topline_1', {})
call term_sendkeys(buf, ":echo line('w0', 1001)\<cr>")
call term_wait(buf)
call VerifyScreenDump(buf, 'Test_diff_topline_2', {})
call term_sendkeys(buf, "\<C-W>p")
call term_wait(buf)
call VerifyScreenDump(buf, 'Test_diff_topline_3', {})
call term_sendkeys(buf, "\<C-W>p")
call term_wait(buf)
call VerifyScreenDump(buf, 'Test_diff_topline_4', {})
call StopVimInTerminal(buf)