]> granicus.if.org Git - vim/commitdiff
patch 8.1.2228: screenpos() returns wrong values when 'number' is set v8.1.2228
authorBram Moolenaar <Bram@vim.org>
Sun, 27 Oct 2019 20:39:09 +0000 (21:39 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 27 Oct 2019 20:39:09 +0000 (21:39 +0100)
Problem:    screenpos() returns wrong values when 'number' is set. (Ben
            Jackson)
Solution:   Compare the column with the window width. (closes #5133)

src/move.c
src/testdir/test_cursor_func.vim
src/version.c

index 97f5ac1b7dd37f6e89875a43bdc772fac19b3708..d6b1c2636f0371dd63d8441d4d9bbf200261db34 100644 (file)
@@ -1217,7 +1217,7 @@ textpos2screenpos(
            col -= rowoff * width;
        }
        col -= wp->w_leftcol;
-       if (col >= width)
+       if (col >= wp->w_width)
            col = -1;
        if (col >= 0)
            coloff = col - scol + wp->w_wincol + 1;
index dc65fdca2c86585b2980d11f6ae3270eeecb1a01..0afc45e58845f58589b441ff8074bae5288d2902 100644 (file)
@@ -100,3 +100,18 @@ func Test_screenpos()
   close
   bwipe!
 endfunc
+
+func Test_screenpos_number()
+  rightbelow new
+  rightbelow 73vsplit
+  call setline (1, repeat('x', 66))
+  setlocal number
+  redraw
+  let winid = win_getid()
+  let [winrow, wincol] = win_screenpos(winid)
+  let pos = screenpos(winid, 1, 66)
+  call assert_equal(winrow, pos.row)
+  call assert_equal(wincol + 66 + 3, pos.col)
+  close
+  bwipe!
+endfunc
index 7b4ebe6b561bedbaed49c47053a5cbdeff6da384..01c95b335f95120019bc12bf4bae763056e96476 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2228,
 /**/
     2227,
 /**/