Mercurial > vim
changeset 36248:736f280a0842 draft v9.1.0759
patch 9.1.0759: screenpos() may return invalid position
Commit: https://github.com/vim/vim/commit/b065a10e245d020c11b521a2a5062300ca9891fc
Author: Christian Brabandt <cb@256bit.org>
Date: Sat Oct 5 17:30:22 2024 +0200
patch 9.1.0759: screenpos() may return invalid position
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: #15792
closes: #15803
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 05 Oct 2024 17:45:02 +0200 |
parents | a3244333f8c4 |
children | 9ac306867c6d |
files | src/option.c src/testdir/test_cursor_func.vim src/version.c |
diffstat | 3 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/option.c +++ b/src/option.c @@ -6737,6 +6737,11 @@ win_copy_options(win_T *wp_from, win_T * void after_copy_winopt(win_T *wp) { + // Set w_leftcol or w_skipcol to zero. + if (wp->w_p_wrap) + wp->w_leftcol = 0; + else + wp->w_skipcol = 0; #ifdef FEAT_LINEBREAK briopt_check(wp); #endif
--- a/src/testdir/test_cursor_func.vim +++ b/src/testdir/test_cursor_func.vim @@ -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'))