Mercurial > vim
changeset 27352:2bec1976362c v8.2.4204
patch 8.2.4204: screenpos() has non-zero row for invisible text
Commit: https://github.com/vim/vim/commit/7924a17791217d50be5a91989a9641bf68e7a735
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 24 16:15:15 2022 +0000
patch 8.2.4204: screenpos() has non-zero row for invisible text
Problem: screenpos() has non-zero row for invisible text.
Solution: Only add the window row when the text is visible. (closes https://github.com/vim/vim/issues/9618)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 24 Jan 2022 17:30:05 +0100 |
parents | 972de339c4de |
children | de73db1d7b54 |
files | src/move.c src/testdir/test_cursor_func.vim src/version.c |
diffstat | 3 files changed, 7 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/move.c +++ b/src/move.c @@ -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;
--- a/src/testdir/test_cursor_func.vim +++ b/src/testdir/test_cursor_func.vim @@ -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