fix(drawline): check filler_todo in place of removed draw_state (#27889)

The only place it matters is the conceal wcol check, but it can avoid
unnecessary computations at other places.
This commit is contained in:
zeertzjq 2024-03-17 05:43:14 +08:00 committed by GitHub
parent 14e4b6bbd8
commit 34b57508a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 11 deletions

View File

@ -1596,7 +1596,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
}
}
if (cul_screenline && wlv.vcol >= left_curline_col && wlv.vcol < right_curline_col) {
if (cul_screenline && wlv.filler_todo <= 0
&& wlv.vcol >= left_curline_col && wlv.vcol < right_curline_col) {
apply_cursorline_highlight(wp, &wlv);
}
@ -1623,7 +1624,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
}
int extmark_attr = 0;
if (area_highlighting || spv->spv_has_spell || extra_check) {
if (wlv.filler_todo <= 0
&& (area_highlighting || spv->spv_has_spell || extra_check)) {
if (wlv.n_extra == 0 || !wlv.extra_for_extmark) {
wlv.reset_extra_attr = false;
}
@ -1654,11 +1656,9 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
}
decor_need_recheck = false;
}
if (wlv.filler_todo <= 0) {
extmark_attr = decor_redraw_col(wp, (colnr_T)(ptr - line),
may_have_inline_virt ? -3 : wlv.off,
selected, &decor_state);
}
extmark_attr = decor_redraw_col(wp, (colnr_T)(ptr - line),
may_have_inline_virt ? -3 : wlv.off,
selected, &decor_state);
if (may_have_inline_virt) {
handle_inline_virtual_text(wp, &wlv, ptr - line, selected);
if (wlv.n_extra > 0 && wlv.virt_inline_hl_mode <= kHlModeReplace) {
@ -2443,7 +2443,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
// the cursor column when we reach its position.
// With 'virtualedit' we may never reach cursor position, but we still
// need to correct the cursor column, so do that at end of line.
if (!did_wcol
if (!did_wcol && wlv.filler_todo <= 0
&& wp == curwin && lnum == wp->w_cursor.lnum
&& conceal_cursor_line(wp)
&& (wlv.vcol + wlv.skip_cells >= wp->w_virtcol || mb_schar == NUL)) {
@ -2705,10 +2705,14 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int col_rows, s
}
}
// Apply lowest-priority line attr now, so everything can override it.
wlv.char_attr = hl_combine_attr(wlv.line_attr_lowprio, wlv.char_attr);
if (wlv.filler_todo <= 0) {
// Apply lowest-priority line attr now, so everything can override it.
wlv.char_attr = hl_combine_attr(wlv.line_attr_lowprio, wlv.char_attr);
}
vcol_prev = wlv.vcol;
if (wlv.filler_todo <= 0) {
vcol_prev = wlv.vcol;
}
// Store character to be displayed.
// Skip characters that are left of the screen for 'nowrap'.

View File

@ -4065,6 +4065,8 @@ describe('decorations: virtual lines', function()
[7] = {foreground = Screen.colors.SlateBlue};
[8] = {background = Screen.colors.WebGray, foreground = Screen.colors.DarkBlue};
[9] = {foreground = Screen.colors.Brown};
[10] = {bold = true, reverse = true};
[11] = {reverse = true};
}
ns = api.nvim_create_namespace 'test'
@ -4860,6 +4862,22 @@ if (h->n_buckets < new_n_buckets) { // expand
]])
end)
it('does not break cursor position with concealcursor #27887', function()
command('vsplit')
insert('\n')
api.nvim_set_option_value('conceallevel', 2, {})
api.nvim_set_option_value('concealcursor', 'niv', {})
api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_lines = {{{'VIRT1'}}, {{'VIRT2'}}} })
screen:expect([[
|
VIRT1 VIRT1 |
VIRT2 VIRT2 |
^ |
{1:~ }{1:~ }|*6
{10:[No Name] [+] }{11:[No Name] [+] }|
|
]])
end)
end)
describe('decorations: signs', function()