mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
vim-patch:9.0.1072: screenpos() column result in fold may be too small
Problem: screenpos() column result in fold may be too small. Solution: Add space of 'number', sign column, etc. (closes vim/vim#11715)ba2d191932
(cherry picked from commit56b77dc171
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
bc6ff78fad
commit
23202944ec
@@ -945,21 +945,18 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
|
|||||||
bool existing_row = (pos->lnum > 0
|
bool existing_row = (pos->lnum > 0
|
||||||
&& pos->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) {
|
||||||
|
const colnr_T off = win_col_off(wp);
|
||||||
if (is_folded) {
|
if (is_folded) {
|
||||||
row += local ? 0 : wp->w_winrow + wp->w_winrow_off;
|
row += local ? 0 : wp->w_winrow + wp->w_winrow_off;
|
||||||
coloff = (local ? 0 : wp->w_wincol + wp->w_wincol_off) + 1;
|
coloff = (local ? 0 : wp->w_wincol + wp->w_wincol_off) + 1 + off;
|
||||||
} else if ((local || visible_row) && existing_row) {
|
} else {
|
||||||
colnr_T off;
|
|
||||||
colnr_T col;
|
|
||||||
int width;
|
|
||||||
|
|
||||||
getvcol(wp, pos, &scol, &ccol, &ecol);
|
getvcol(wp, pos, &scol, &ccol, &ecol);
|
||||||
|
|
||||||
// similar to what is done in validate_cursor_col()
|
// similar to what is done in validate_cursor_col()
|
||||||
col = scol;
|
colnr_T col = scol;
|
||||||
off = win_col_off(wp);
|
|
||||||
col += off;
|
col += off;
|
||||||
width = wp->w_width - off + win_col_off2(wp);
|
int width = wp->w_width - off + win_col_off2(wp);
|
||||||
|
|
||||||
// long line wrapping, adjust row
|
// long line wrapping, adjust row
|
||||||
if (wp->w_p_wrap && col >= (colnr_T)wp->w_width && width > 0) {
|
if (wp->w_p_wrap && col >= (colnr_T)wp->w_width && width > 0) {
|
||||||
@@ -983,6 +980,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
*rowp = row + rowoff;
|
*rowp = row + rowoff;
|
||||||
*scolp = scol + coloff;
|
*scolp = scol + coloff;
|
||||||
*ccolp = ccol + coloff;
|
*ccolp = ccol + coloff;
|
||||||
|
@@ -138,8 +138,12 @@ func Test_screenpos_fold()
|
|||||||
redraw
|
redraw
|
||||||
call assert_equal(2, screenpos(1, 2, 1).row)
|
call assert_equal(2, screenpos(1, 2, 1).row)
|
||||||
call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 3, 1))
|
call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 3, 1))
|
||||||
call assert_equal(3, screenpos(1, 4, 1).row)
|
call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 4, 1))
|
||||||
call assert_equal(3, screenpos(1, 5, 1).row)
|
call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 5, 1))
|
||||||
|
setlocal number
|
||||||
|
call assert_equal(#{col: 5, row: 3, endcol: 5, curscol: 5}, screenpos(1, 3, 1))
|
||||||
|
call assert_equal(#{col: 5, row: 3, endcol: 5, curscol: 5}, screenpos(1, 4, 1))
|
||||||
|
call assert_equal(#{col: 5, row: 3, endcol: 5, curscol: 5}, screenpos(1, 5, 1))
|
||||||
call assert_equal(4, screenpos(1, 6, 1).row)
|
call assert_equal(4, screenpos(1, 6, 1).row)
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
Reference in New Issue
Block a user