aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2025-03-15 16:18:23 +0100
committerGitHub <noreply@github.com>2025-03-15 08:18:23 -0700
commit19fc65acbc670869781fb4148176b8abd94fba29 (patch)
treefd481ac73e6332d1113da11a89269fc32f24e613 /src
parentf8d5811c717bbfa7b7d078211f4a5468eb0ff088 (diff)
downloadrneovim-19fc65acbc670869781fb4148176b8abd94fba29.tar.gz
rneovim-19fc65acbc670869781fb4148176b8abd94fba29.tar.bz2
rneovim-19fc65acbc670869781fb4148176b8abd94fba29.zip
fix(statuscolumn): misleading v:lnum for virtual lines #32912
Problem: Virtual 'statuscolumn' lines are evaluated with a misleading v:(rel)num. Namely set to the line above for `virt_lines_above = true` lines, or even the last drawn line for a partial redraw. Solution: Set `v:lnum` for the first evaluated row of a line, first above virtual line of a row and first non-virtual line of a row.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/drawline.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c
index 9e65abe3e4..16e3a95121 100644
--- a/src/nvim/drawline.c
+++ b/src/nvim/drawline.c
@@ -664,11 +664,15 @@ static void draw_lnum_col(win_T *wp, winlinevars_T *wlv)
}
/// Build and draw the 'statuscolumn' string for line "lnum" in window "wp".
-static void draw_statuscol(win_T *wp, winlinevars_T *wlv, linenr_T lnum, int virtnum, int col_rows,
+static void draw_statuscol(win_T *wp, winlinevars_T *wlv, int virtnum, int col_rows,
statuscol_T *stcp)
{
- // When called for the first non-filler row of line "lnum" set num v:vars
- linenr_T relnum = virtnum == 0 ? abs(get_cursor_rel_lnum(wp, lnum)) : -1;
+ // Adjust lnum for filler lines belonging to the line above and set lnum v:vars for first
+ // row, first non-filler line, and first filler line belonging to the current line.
+ linenr_T lnum = wlv->lnum - ((wlv->n_virt_lines - wlv->filler_todo) < wlv->n_virt_below);
+ linenr_T relnum = (virtnum == -wlv->filler_lines || virtnum == 0
+ || virtnum == (wlv->n_virt_below - wlv->filler_lines))
+ ? abs(get_cursor_rel_lnum(wp, lnum)) : -1;
char buf[MAXPATHL];
// When a buffer's line count has changed, make a best estimate for the full
@@ -1639,7 +1643,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, b
} else if (statuscol.draw) {
// Draw 'statuscolumn' if it is set.
const int v = (int)(ptr - line);
- draw_statuscol(wp, &wlv, lnum, wlv.row - startrow - wlv.filler_lines, col_rows, &statuscol);
+ draw_statuscol(wp, &wlv, wlv.row - startrow - wlv.filler_lines, col_rows, &statuscol);
if (wp->w_redr_statuscol) {
break;
}