mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
vim-patch:9.1.0759: screenpos() may return invalid position (#30681)
Problem: screenpos() may return invalid position after switching buffers (Greg Hurrell) Solution: reset w_leftcol if wrapping has been set after copying wrap option fixes: vim/vim#15792 closes: vim/vim#15803b065a10e24
Co-authored-by: Christian Brabandt <cb@256bit.org> (cherry picked from commit9f26bdc416
)
This commit is contained in:
committed by
github-actions[bot]
parent
82ea8a7c3f
commit
ee7885aa21
@ -5076,6 +5076,12 @@ void clear_winopt(winopt_T *wop)
|
||||
|
||||
void didset_window_options(win_T *wp, bool valid_cursor)
|
||||
{
|
||||
// Set w_leftcol or w_skipcol to zero.
|
||||
if (wp->w_p_wrap) {
|
||||
wp->w_leftcol = 0;
|
||||
} else {
|
||||
wp->w_skipcol = 0;
|
||||
}
|
||||
check_colorcolumn(wp);
|
||||
briopt_check(wp);
|
||||
fill_culopt_flags(NULL, wp);
|
||||
|
@ -279,6 +279,21 @@ func Test_screenpos_number()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_screenpos_edit_newfile()
|
||||
new
|
||||
20vsp
|
||||
setl nowrap
|
||||
call setline(1, 'abcdefghijklmnopqrstuvwxyz')
|
||||
call cursor(1, 10)
|
||||
norm! 5zl
|
||||
call assert_equal(#{col: 5, row: 1, endcol: 5, curscol: 5}, screenpos(win_getid(), 1, 10))
|
||||
enew!
|
||||
call assert_equal(1, &l:wrap)
|
||||
call assert_equal(#{col: 1, row: 1, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1))
|
||||
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" Save the visual start character position
|
||||
func SaveVisualStartCharPos()
|
||||
call add(g:VisualStartPos, getcharpos('v'))
|
||||
|
Reference in New Issue
Block a user