From 435dee74bb3593b778328138dac054f26e2d7396 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 27 Apr 2024 06:32:25 +0800 Subject: vim-patch:9.1.0374: wrong botline in BufEnter (#28530) Problem: When :edit an existing buffer, line('w$') may return a wrong result. Solution: Reset w_valid in curwin_init() (Jaehwang Jung) `do_ecmd()` reinitializes the current window (`curwin_init()`) whose `w_valid` field may have `VALID_BOTLINE` set. Resetting `w_botline` without marking it as invalid makes subsequent `validate_botline()` calls a no-op, thus resulting in wrong `line('w$')` value. closes: vim/vim#14642 https://github.com/vim/vim/commit/eb80b8304efb6dfeaa8d01dd41fe281df4894240 Co-authored-by: Jaehwang Jung --- test/old/testdir/test_autocmd.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/old/testdir/test_autocmd.vim b/test/old/testdir/test_autocmd.vim index 7a9799107a..ddc595e116 100644 --- a/test/old/testdir/test_autocmd.vim +++ b/test/old/testdir/test_autocmd.vim @@ -4105,4 +4105,16 @@ func Test_SwapExists_set_other_buf_modified() bwipe! endfunc +func Test_BufEnter_botline() + set hidden + call writefile(range(10), 'Xxx1', 'D') + call writefile(range(20), 'Xxx2', 'D') + edit Xxx1 + edit Xxx2 + au BufEnter Xxx1 call assert_true(line('w$') > 1) + edit Xxx1 + au! BufEnter Xxx1 + set hidden&vim +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit