summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Brabandt <cb@256bit.org>2024-10-05 17:30:22 +0200
committerChristian Brabandt <cb@256bit.org>2024-10-05 17:30:22 +0200
commitb065a10e245d020c11b521a2a5062300ca9891fc (patch)
tree783955446d0694e1b2790e041d791cd12587528d
parent7c3f9af0ed5dd7035f8a3fbb2f0bf965a453e359 (diff)
patch 9.1.0759: screenpos() may return invalid positionv9.1.0759
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>
-rw-r--r--src/option.c5
-rw-r--r--src/testdir/test_cursor_func.vim15
-rw-r--r--src/version.c2
3 files changed, 22 insertions, 0 deletions
diff --git a/src/option.c b/src/option.c
index b38d77f5ac..df0b647c09 100644
--- a/src/option.c
+++ b/src/option.c
@@ -6737,6 +6737,11 @@ win_copy_options(win_T *wp_from, win_T *wp_to)
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
diff --git a/src/testdir/test_cursor_func.vim b/src/testdir/test_cursor_func.vim
index 2bdda869e6..8766f97d9d 100644
--- 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'))
diff --git a/src/version.c b/src/version.c
index 047db755e1..63a6bc0879 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 759,
+/**/
758,
/**/
757,