aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-05-17 17:33:27 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-05-21 16:56:55 -0400
commit9cdea8148c7a22a9d8050dd1586cb8dc4570285b (patch)
tree8c38792c4898c671643e8b902249917fd4ead834
parent63966a9ec240369dba246985779774df2d2cff9c (diff)
downloadrneovim-9cdea8148c7a22a9d8050dd1586cb8dc4570285b.tar.gz
rneovim-9cdea8148c7a22a9d8050dd1586cb8dc4570285b.tar.bz2
rneovim-9cdea8148c7a22a9d8050dd1586cb8dc4570285b.zip
vim-patch:8.1.2228: screenpos() returns wrong values when 'number' is set
Problem: screenpos() returns wrong values when 'number' is set. (Ben Jackson) Solution: Compare the column with the window width. (closes vim/vim#5133) https://github.com/vim/vim/commit/38ba4dce4a8574e60f6ddb111922880b0c7affdc
-rw-r--r--src/nvim/move.c2
-rw-r--r--src/nvim/testdir/test_cursor_func.vim15
2 files changed, 16 insertions, 1 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c
index d4f82bc601..8a8a639a52 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -996,7 +996,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp,
col -= wp->w_leftcol;
- if (col >= 0 && col < width) {
+ if (col >= 0 && col < wp->w_width) {
coloff = col - scol + (local ? 0 : wp->w_wincol) + 1;
} else {
scol = ccol = ecol = 0;
diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim
index e8e561dfd8..2e190911b2 100644
--- a/src/nvim/testdir/test_cursor_func.vim
+++ b/src/nvim/testdir/test_cursor_func.vim
@@ -93,3 +93,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