aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-06 08:00:30 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-12-06 08:02:39 +0800
commit52b3e8bdef6896b53d3c4ee3fbc7d8ae5f480948 (patch)
tree398ac9cef36abf57591ff66e62d958ea53ce271b
parent0909d987fe925483dc513ae330179339899cd0a5 (diff)
downloadrneovim-52b3e8bdef6896b53d3c4ee3fbc7d8ae5f480948.tar.gz
rneovim-52b3e8bdef6896b53d3c4ee3fbc7d8ae5f480948.tar.bz2
rneovim-52b3e8bdef6896b53d3c4ee3fbc7d8ae5f480948.zip
vim-patch:9.0.1016: screenpos() does not count filler lines for diff mode
Problem: screenpos() does not count filler lines for diff mode. Solution: Add filler lines. (closes 11658) https://github.com/vim/vim/commit/1cb16c3a20a9d17df1a8dc3813ef64dc98e42637 Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--src/nvim/move.c2
-rw-r--r--src/nvim/testdir/test_cursor_func.vim16
2 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 17e3ef74cc..6882c81816 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -926,6 +926,8 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
linenr_T lnum = pos->lnum;
is_folded = hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
row = plines_m_win(wp, wp->w_topline, lnum - 1) + 1;
+ // Add filler lines above this buffer line.
+ row += win_get_fill(wp, lnum);
visible_row = true;
} else if (!local || pos->lnum < wp->w_topline) {
row = 0;
diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim
index 634b27b0ed..2151076cb9 100644
--- a/src/nvim/testdir/test_cursor_func.vim
+++ b/src/nvim/testdir/test_cursor_func.vim
@@ -144,6 +144,22 @@ func Test_screenpos_fold()
bwipe!
endfunc
+func Test_screenpos_diff()
+ CheckFeature diff
+
+ enew!
+ call setline(1, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'])
+ vnew
+ call setline(1, ['a', 'b', 'c', 'g', 'h', 'i'])
+ windo diffthis
+ wincmd w
+ call assert_equal(#{col: 3, row: 7, endcol: 3, curscol: 3}, screenpos(0, 4, 1))
+
+ windo diffoff
+ bwipe!
+ bwipe!
+endfunc
+
func Test_screenpos_number()
rightbelow new
rightbelow 73vsplit