mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
vim-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 vim/vim#9618)7924a17791
Co-authored-by: Bram Moolenaar <Bram@vim.org> (cherry picked from commit6f9cda0f0a
)
This commit is contained in:
parent
bc4d11cd9d
commit
ebfe54617f
@ -931,7 +931,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
|
||||
if (pos->lnum >= wp->w_topline && pos->lnum <= wp->w_botline) {
|
||||
row = plines_m_win(wp, wp->w_topline, pos->lnum - 1) + 1;
|
||||
visible_row = true;
|
||||
} else if (pos->lnum < wp->w_topline) {
|
||||
} else if (!local || pos->lnum < wp->w_topline) {
|
||||
row = 0;
|
||||
} else {
|
||||
row = wp->w_height_inner;
|
||||
@ -964,6 +964,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
|
||||
|
||||
if (col >= 0 && col < wp->w_width && row + rowoff <= wp->w_height) {
|
||||
coloff = col - scol + (local ? 0 : wp->w_wincol + wp->w_wincol_off) + 1;
|
||||
row += local ? 0 : wp->w_winrow + wp->w_winrow_off;
|
||||
} else {
|
||||
// character is left, right or below of the window
|
||||
scol = ccol = ecol = 0;
|
||||
@ -974,7 +975,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
|
||||
}
|
||||
}
|
||||
}
|
||||
*rowp = (local ? 0 : wp->w_winrow + wp->w_winrow_off) + row + rowoff;
|
||||
*rowp = row + rowoff;
|
||||
*scolp = scol + coloff;
|
||||
*ccolp = ccol + coloff;
|
||||
*ecolp = ecol + coloff;
|
||||
|
@ -109,7 +109,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
|
||||
|
Loading…
Reference in New Issue
Block a user