mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
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
eb80b8304e
Co-authored-by: Jaehwang Jung <tomtomjhj@gmail.com>
This commit is contained in:
parent
694756252b
commit
435dee74bb
@ -47,8 +47,8 @@ typedef struct {
|
|||||||
#define VALID_VIRTCOL 0x04 // w_virtcol (file col) is valid
|
#define VALID_VIRTCOL 0x04 // w_virtcol (file col) is valid
|
||||||
#define VALID_CHEIGHT 0x08 // w_cline_height and w_cline_folded valid
|
#define VALID_CHEIGHT 0x08 // w_cline_height and w_cline_folded valid
|
||||||
#define VALID_CROW 0x10 // w_cline_row is valid
|
#define VALID_CROW 0x10 // w_cline_row is valid
|
||||||
#define VALID_BOTLINE 0x20 // w_botine and w_empty_rows are valid
|
#define VALID_BOTLINE 0x20 // w_botline and w_empty_rows are valid
|
||||||
#define VALID_BOTLINE_AP 0x40 // w_botine is approximated
|
#define VALID_BOTLINE_AP 0x40 // w_botline is approximated
|
||||||
#define VALID_TOPLINE 0x80 // w_topline is valid (for cursor position)
|
#define VALID_TOPLINE 0x80 // w_topline is valid (for cursor position)
|
||||||
|
|
||||||
// flags for b_flags
|
// flags for b_flags
|
||||||
|
@ -2467,6 +2467,7 @@ void win_init_empty(win_T *wp)
|
|||||||
wp->w_topline = 1;
|
wp->w_topline = 1;
|
||||||
wp->w_topfill = 0;
|
wp->w_topfill = 0;
|
||||||
wp->w_botline = 2;
|
wp->w_botline = 2;
|
||||||
|
wp->w_valid = 0;
|
||||||
wp->w_s = &wp->w_buffer->b_s;
|
wp->w_s = &wp->w_buffer->b_s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4105,4 +4105,16 @@ func Test_SwapExists_set_other_buf_modified()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
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
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user