From 49ede0a68f1f8fd46dc9715fb1f332a13d13dbe3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 5 Jun 2023 06:33:43 +0800 Subject: vim-patch:9.0.1600: screenpos() does not take w_skipcol into account Problem: screenpos() does not take w_skipcol into account. Solution: Subtract w_skipcol from column. (closes vim/vim#12486, closes vim/vim#12476) https://github.com/vim/vim/commit/f0e68c0e2a3539f899e737e5b167622fe081fbbd --- src/nvim/move.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim') diff --git a/src/nvim/move.c b/src/nvim/move.c index 48691db26d..57466120e9 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1098,6 +1098,10 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp, col += off; int width = wp->w_width_inner - off + win_col_off2(wp); + if (pos->lnum == wp->w_topline) { + col -= wp->w_skipcol; + } + // long line wrapping, adjust row if (wp->w_p_wrap && col >= (colnr_T)wp->w_width_inner && width > 0) { // use same formula as what is used in curs_columns() -- cgit From 57fef392d265e2ef40c8c514749d658cb4d8d22a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 5 Jun 2023 06:40:39 +0800 Subject: 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) https://github.com/vim/vim/commit/55daae392157823dc5434e6be1344f4336bfe96f --- src/nvim/move.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/nvim') diff --git a/src/nvim/move.c b/src/nvim/move.c index 57466120e9..4a6c2e1934 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1069,21 +1069,20 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp, bool visible_row = 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); row = plines_m_win(wp, wp->w_topline, lnum - 1) + 1; // 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; - } else if (!local || pos->lnum < wp->w_topline) { + } else if (!local || lnum < wp->w_topline) { row = 0; } else { row = wp->w_height_inner; } - bool existing_row = (pos->lnum > 0 - && pos->lnum <= wp->w_buffer->b_ml.ml_line_count); + bool existing_row = (lnum > 0 && lnum <= wp->w_buffer->b_ml.ml_line_count); if ((local || visible_row) && existing_row) { 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; 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; } -- cgit From 7955c90621bb679f9c16b6788fbcb6145739886f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 5 Jun 2023 06:58:44 +0800 Subject: fix(plines): folded lines with virt_lines attached to line above --- src/nvim/move.c | 1 + src/nvim/plines.c | 15 +++++---------- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'src/nvim') diff --git a/src/nvim/move.c b/src/nvim/move.c index 4a6c2e1934..6fb6656472 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1090,6 +1090,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp, row += local ? 0 : wp->w_winrow + wp->w_winrow_off; coloff = (local ? 0 : wp->w_wincol + wp->w_wincol_off) + 1 + off; } else { + assert(lnum == pos->lnum); getvcol(wp, pos, &scol, &ccol, &ecol); // similar to what is done in validate_cursor_col() diff --git a/src/nvim/plines.c b/src/nvim/plines.c index 25c745ae97..5f28715f53 100644 --- a/src/nvim/plines.c +++ b/src/nvim/plines.c @@ -38,8 +38,7 @@ /// @param winheight when true limit to window height int plines_win(win_T *wp, linenr_T lnum, bool winheight) { - // Check for filler lines above this buffer line. When folded the result - // is one line anyway. + // Check for filler lines above this buffer line. return plines_win_nofill(wp, lnum, winheight) + win_get_fill(wp, lnum); } @@ -199,16 +198,12 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column) int plines_win_full(win_T *wp, linenr_T lnum, linenr_T *const nextp, bool *const foldedp, const bool cache, const bool winheight) { - bool folded = hasFoldingWin(wp, lnum, NULL, nextp, cache, NULL); - if (foldedp) { + bool folded = hasFoldingWin(wp, lnum, &lnum, nextp, cache, NULL); + if (foldedp != NULL) { *foldedp = folded; } - if (folded) { - return 1; - } else if (lnum == wp->w_topline) { - return plines_win_nofill(wp, lnum, winheight) + wp->w_topfill; - } - return plines_win(wp, lnum, winheight); + return ((folded ? 1 : plines_win_nofill(wp, lnum, winheight)) + + (lnum == wp->w_topline ? wp->w_topfill : win_get_fill(wp, lnum))); } int plines_m_win(win_T *wp, linenr_T first, linenr_T last) -- cgit