fix(api): don't use stl 'fillchar' for "use_statuscol_lnum" (#27501)

Problem:  nvim_eval_statusline() uses "stl" from 'fillchars' with "use_statuscol_lnum".
Solution: Reorder "fillchar" else chain.
This commit is contained in:
luukvbaal 2024-02-17 00:44:31 +01:00 committed by GitHub
parent 478273a423
commit 5fd1bac65e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 40 deletions

View File

@ -2203,49 +2203,44 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Arena *
statuscol_T statuscol = { 0 };
SignTextAttrs sattrs[SIGN_SHOW_MAX] = { 0 };
if (opts->use_tabline) {
fillchar = schar_from_ascii(' ');
} else {
if (fillchar == 0) {
if (opts->use_winbar) {
fillchar = wp->w_p_fcs_chars.wbr;
} else {
int attr;
fillchar = fillchar_status(&attr, wp);
if (statuscol_lnum) {
int line_id = 0;
int cul_id = 0;
int num_id = 0;
linenr_T lnum = statuscol_lnum;
decor_redraw_signs(wp, wp->w_buffer, lnum - 1, sattrs, &line_id, &cul_id, &num_id);
statuscol.sattrs = sattrs;
statuscol.foldinfo = fold_info(wp, lnum);
wp->w_cursorline = win_cursorline_standout(wp) ? wp->w_cursor.lnum : 0;
if (wp->w_p_cul) {
if (statuscol.foldinfo.fi_level != 0 && statuscol.foldinfo.fi_lines > 0) {
wp->w_cursorline = statuscol.foldinfo.fi_lnum;
}
statuscol.use_cul = lnum == wp->w_cursorline && (wp->w_p_culopt_flags & CULOPT_NBR);
}
if (statuscol_lnum) {
int line_id = 0;
int cul_id = 0;
int num_id = 0;
linenr_T lnum = statuscol_lnum;
decor_redraw_signs(wp, wp->w_buffer, lnum - 1, sattrs, &line_id, &cul_id, &num_id);
statuscol.sattrs = sattrs;
statuscol.foldinfo = fold_info(wp, lnum);
wp->w_cursorline = win_cursorline_standout(wp) ? wp->w_cursor.lnum : 0;
statuscol.sign_cul_id = statuscol.use_cul ? cul_id : 0;
if (num_id) {
stc_hl_id = num_id;
} else if (statuscol.use_cul) {
stc_hl_id = HLF_CLN + 1;
} else if (wp->w_p_rnu) {
stc_hl_id = (lnum < wp->w_cursor.lnum ? HLF_LNA : HLF_LNB) + 1;
} else {
stc_hl_id = HLF_N + 1;
}
if (wp->w_p_cul) {
if (statuscol.foldinfo.fi_level != 0 && statuscol.foldinfo.fi_lines > 0) {
wp->w_cursorline = statuscol.foldinfo.fi_lnum;
}
statuscol.use_cul = lnum == wp->w_cursorline && (wp->w_p_culopt_flags & CULOPT_NBR);
}
statuscol.sign_cul_id = statuscol.use_cul ? cul_id : 0;
if (num_id) {
stc_hl_id = num_id;
} else if (statuscol.use_cul) {
stc_hl_id = HLF_CLN + 1;
} else if (wp->w_p_rnu) {
stc_hl_id = (lnum < wp->w_cursor.lnum ? HLF_LNA : HLF_LNB) + 1;
} else {
stc_hl_id = HLF_N + 1;
}
set_vim_var_nr(VV_LNUM, lnum);
set_vim_var_nr(VV_RELNUM, labs(get_cursor_rel_lnum(wp, lnum)));
set_vim_var_nr(VV_VIRTNUM, 0);
set_vim_var_nr(VV_LNUM, lnum);
set_vim_var_nr(VV_RELNUM, labs(get_cursor_rel_lnum(wp, lnum)));
set_vim_var_nr(VV_VIRTNUM, 0);
} else if (fillchar == 0 && !opts->use_tabline) {
if (opts->use_winbar) {
fillchar = wp->w_p_fcs_chars.wbr;
} else {
int attr;
fillchar = fillchar_status(&attr, wp);
}
}

View File

@ -3806,7 +3806,8 @@ describe('API', function()
it('works with statuscolumn', function()
exec([[
let &stc='%C%s%=%l '
set cul nu nuw=3 scl=yes:2 fdc=2
" should not use "stl" from 'fillchars'
set cul nu nuw=3 scl=yes:2 fdc=2 fillchars=stl:#
call setline(1, repeat(['aaaaa'], 5))
let g:ns = nvim_create_namespace('')
call sign_define('a', {'text':'aa', 'texthl':'IncSearch', 'numhl':'Normal'})