]> granicus.if.org Git - vim/commitdiff
patch 8.2.4204: screenpos() has non-zero row for invisible text v8.2.4204
authorBram Moolenaar <Bram@vim.org>
Mon, 24 Jan 2022 16:15:15 +0000 (16:15 +0000)
committerBram Moolenaar <Bram@vim.org>
Mon, 24 Jan 2022 16:15:15 +0000 (16:15 +0000)
Problem:    screenpos() has non-zero row for invisible text.
Solution:   Only add the window row when the text is visible. (closes #9618)

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

index b8e8780aa54afeb066f1e0d1332e3dc006676394..f52e4c071e48549fc3592aa5ed416c4b28d9de45 100644 (file)
@@ -1262,12 +1262,15 @@ textpos2screenpos(
        if (col >= wp->w_width)
            col = -1;
        if (col >= 0 && row + rowoff <= wp->w_height)
+       {
            coloff = col - scol + wp->w_wincol + 1;
+           row += W_WINROW(wp);
+       }
        else
            // character is left, right or below of the window
            row = rowoff = scol = ccol = ecol = 0;
     }
-    *rowp = W_WINROW(wp) + row + rowoff;
+    *rowp = row + rowoff;
     *scolp = scol + coloff;
     *ccolp = ccol + coloff;
     *ecolp = ecol + coloff;
index 965c70496066ca387883e1ba1dd92f99cbc938df..bc12511aff33f01cf60214fda9872f4eb3bf9dae 100644 (file)
@@ -124,7 +124,7 @@ func Test_screenpos()
        \ 'col': wincol + 7,
        \ 'curscol': wincol + 7,
        \ 'endcol': wincol + 7}, winid->screenpos(line('$'), 8))
-  call assert_equal({'row': winrow - 1, 'col': 0, 'curscol': 0, 'endcol': 0},
+  call assert_equal({'row': 0, 'col': 0, 'curscol': 0, 'endcol': 0},
         \ winid->screenpos(line('$'), 22))
 
   close
index c75fe99375b3bc35ffcbd6cfc27a81abebfbdc20..2208c1c2ad84dd137e7dbe9a6462150724c84564 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4204,
 /**/
     4203,
 /**/