mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:9.0.1607: screenpos() returns wrong row with diff filler lines
Problem: screenpos() returns wrong row with diff filler lines.
Solution: Only add filler lines when appropriate. Also don't add the
'smoothscroll' marker when w_skipcol is zero. (closes vim/vim#12485,
closes vim/vim#12484)
55daae3921
This commit is contained in:
parent
49ede0a68f
commit
57fef392d2
@ -1069,21 +1069,20 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
|
|||||||
bool visible_row = false;
|
bool visible_row = false;
|
||||||
bool is_folded = false;
|
bool is_folded = false;
|
||||||
|
|
||||||
if (pos->lnum >= wp->w_topline && pos->lnum <= wp->w_botline) {
|
linenr_T lnum = pos->lnum;
|
||||||
linenr_T lnum = pos->lnum;
|
if (lnum >= wp->w_topline && lnum <= wp->w_botline) {
|
||||||
is_folded = hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
|
is_folded = hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
|
||||||
row = plines_m_win(wp, wp->w_topline, lnum - 1) + 1;
|
row = plines_m_win(wp, wp->w_topline, lnum - 1) + 1;
|
||||||
// Add filler lines above this buffer line.
|
// Add filler lines above this buffer line.
|
||||||
row += win_get_fill(wp, lnum);
|
row += lnum == wp->w_topline ? wp->w_topfill : win_get_fill(wp, lnum);
|
||||||
visible_row = true;
|
visible_row = true;
|
||||||
} else if (!local || pos->lnum < wp->w_topline) {
|
} else if (!local || lnum < wp->w_topline) {
|
||||||
row = 0;
|
row = 0;
|
||||||
} else {
|
} else {
|
||||||
row = wp->w_height_inner;
|
row = wp->w_height_inner;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool existing_row = (pos->lnum > 0
|
bool existing_row = (lnum > 0 && lnum <= wp->w_buffer->b_ml.ml_line_count);
|
||||||
&& pos->lnum <= wp->w_buffer->b_ml.ml_line_count);
|
|
||||||
|
|
||||||
if ((local || visible_row) && existing_row) {
|
if ((local || visible_row) && existing_row) {
|
||||||
const colnr_T off = win_col_off(wp);
|
const colnr_T off = win_col_off(wp);
|
||||||
@ -1098,7 +1097,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
|
|||||||
col += off;
|
col += off;
|
||||||
int width = wp->w_width_inner - off + win_col_off2(wp);
|
int width = wp->w_width_inner - off + win_col_off2(wp);
|
||||||
|
|
||||||
if (pos->lnum == wp->w_topline) {
|
if (lnum == wp->w_topline) {
|
||||||
col -= wp->w_skipcol;
|
col -= wp->w_skipcol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,13 +130,14 @@ func Test_screenpos()
|
|||||||
1split
|
1split
|
||||||
normal G$
|
normal G$
|
||||||
redraw
|
redraw
|
||||||
|
" w_skipcol should be subtracted
|
||||||
call assert_equal({'row': winrow + 0,
|
call assert_equal({'row': winrow + 0,
|
||||||
\ 'col': wincol + 20 - 1,
|
\ 'col': wincol + 20 - 1,
|
||||||
\ 'curscol': wincol + 20 - 1,
|
\ 'curscol': wincol + 20 - 1,
|
||||||
\ 'endcol': wincol + 20 - 1},
|
\ 'endcol': wincol + 20 - 1},
|
||||||
\ screenpos(win_getid(), line('.'), col('.')))
|
\ screenpos(win_getid(), line('.'), col('.')))
|
||||||
|
|
||||||
" w_skipcol should be subtracted
|
" w_leftcol should be subtracted
|
||||||
setlocal nowrap
|
setlocal nowrap
|
||||||
normal 050zl$
|
normal 050zl$
|
||||||
call assert_equal({'row': winrow + 0,
|
call assert_equal({'row': winrow + 0,
|
||||||
@ -203,6 +204,19 @@ func Test_screenpos_diff()
|
|||||||
windo diffthis
|
windo diffthis
|
||||||
wincmd w
|
wincmd w
|
||||||
call assert_equal(#{col: 3, row: 7, endcol: 3, curscol: 3}, screenpos(0, 4, 1))
|
call assert_equal(#{col: 3, row: 7, endcol: 3, curscol: 3}, screenpos(0, 4, 1))
|
||||||
|
call assert_equal(#{col: 3, row: 8, endcol: 3, curscol: 3}, screenpos(0, 5, 1))
|
||||||
|
exe "normal! 3\<C-E>"
|
||||||
|
call assert_equal(#{col: 3, row: 4, endcol: 3, curscol: 3}, screenpos(0, 4, 1))
|
||||||
|
call assert_equal(#{col: 3, row: 5, endcol: 3, curscol: 3}, screenpos(0, 5, 1))
|
||||||
|
exe "normal! \<C-E>"
|
||||||
|
call assert_equal(#{col: 3, row: 3, endcol: 3, curscol: 3}, screenpos(0, 4, 1))
|
||||||
|
call assert_equal(#{col: 3, row: 4, endcol: 3, curscol: 3}, screenpos(0, 5, 1))
|
||||||
|
exe "normal! \<C-E>"
|
||||||
|
call assert_equal(#{col: 3, row: 2, endcol: 3, curscol: 3}, screenpos(0, 4, 1))
|
||||||
|
call assert_equal(#{col: 3, row: 3, endcol: 3, curscol: 3}, screenpos(0, 5, 1))
|
||||||
|
exe "normal! \<C-E>"
|
||||||
|
call assert_equal(#{col: 3, row: 1, endcol: 3, curscol: 3}, screenpos(0, 4, 1))
|
||||||
|
call assert_equal(#{col: 3, row: 2, endcol: 3, curscol: 3}, screenpos(0, 5, 1))
|
||||||
|
|
||||||
windo diffoff
|
windo diffoff
|
||||||
bwipe!
|
bwipe!
|
||||||
|
Loading…
Reference in New Issue
Block a user