feat(decorations): support more than one virt_lines block

This commit is contained in:
Björn Linse
2021-10-13 21:35:37 +02:00
parent 8ade2f5b04
commit 8d7816cf27
13 changed files with 130 additions and 106 deletions

View File

@@ -2372,11 +2372,12 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
filler_lines = 0;
area_highlighting = true;
}
int virtual_lines = decor_virtual_lines(wp, lnum);
filler_lines += virtual_lines;
VirtLines virt_lines = KV_INITIAL_VALUE;
int n_virt_lines = decor_virt_lines(wp, lnum, &virt_lines);
filler_lines += n_virt_lines;
if (lnum == wp->w_topline) {
filler_lines = wp->w_topfill;
virtual_lines = MIN(virtual_lines, filler_lines);
n_virt_lines = MIN(n_virt_lines, filler_lines);
}
filler_todo = filler_lines;
@@ -2904,7 +2905,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
if (draw_state == WL_SBR - 1 && n_extra == 0) {
draw_state = WL_SBR;
if (filler_todo > filler_lines - virtual_lines) {
if (filler_todo > filler_lines - n_virt_lines) {
// TODO(bfredl): check this doesn't inhibit TUI-style
// clear-to-end-of-line.
c_extra = ' ';
@@ -4423,12 +4424,12 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
int draw_col = col - boguscols;
if (filler_todo > 0) {
int index = filler_todo - (filler_lines - virtual_lines);
int index = filler_todo - (filler_lines - n_virt_lines);
if (index > 0) {
int fpos = kv_size(buf->b_virt_lines) - index;
assert(fpos >= 0);
int offset = buf->b_virt_line_leftcol ? 0 : win_col_offset;
draw_virt_text_item(buf, offset, kv_A(buf->b_virt_lines, fpos),
int i = kv_size(virt_lines) - index;
assert(i >= 0);
int offset = kv_A(virt_lines, i).left_col ? 0 : win_col_offset;
draw_virt_text_item(buf, offset, kv_A(virt_lines, i).line,
kHlModeReplace, grid->Columns, offset);
}
} else {
@@ -4506,6 +4507,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool noc
cap_col = 0;
}
kv_destroy(virt_lines);
xfree(p_extra_free);
return row;
}