diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-02-14 14:36:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-14 14:36:12 +0000 |
commit | 00c0a52f94184e49e342b1898831e1d8ee10c543 (patch) | |
tree | acddfd30dfa25047a94628bd8cb465ed4d7fc288 /src/nvim/drawline.c | |
parent | ff3d04b75b4a9314815c37d53ebc4d035a043335 (diff) | |
parent | a4e376f09b30250e4e464a7c8b6c5278f0943ced (diff) | |
download | rneovim-00c0a52f94184e49e342b1898831e1d8ee10c543.tar.gz rneovim-00c0a52f94184e49e342b1898831e1d8ee10c543.tar.bz2 rneovim-00c0a52f94184e49e342b1898831e1d8ee10c543.zip |
Merge pull request #22108 from luukvbaal/statuscolumn
perf(column): only build fold/sign column when present in 'statuscolumn'
Diffstat (limited to 'src/nvim/drawline.c')
-rw-r--r-- | src/nvim/drawline.c | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 3bd55dbe09..a74a5670d1 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -404,37 +404,10 @@ static int get_sign_attrs(buf_T *buf, linenr_T lnum, SignTextAttrs *sattrs, int /// the start of the buffer line "lnum" and once for the wrapped lines. /// /// @param[out] stcp Status column attributes -static void get_statuscol_str(win_T *wp, linenr_T lnum, int row, int startrow, int filler_lines, - int cul_attr, int sign_num_attr, int sign_cul_attr, statuscol_T *stcp, - foldinfo_T foldinfo, SignTextAttrs *sattrs) +static void get_statuscol_str(win_T *wp, linenr_T lnum, int virtnum, statuscol_T *stcp) { - long relnum = -1; - bool use_cul = use_cursor_line_sign(wp, lnum); - int virtnum = row - startrow - filler_lines; - - // When called the first time for line "lnum" set num_attr - if (stcp->num_attr == 0) { - stcp->num_attr = sign_num_attr ? sign_num_attr - : get_line_number_attr(wp, lnum, row, startrow, filler_lines); - } - // When called for the first non-filler row of line "lnum" set num v:vars and fold column - if (virtnum == 0) { - relnum = labs(get_cursor_rel_lnum(wp, lnum)); - if (compute_foldcolumn(wp, 0)) { - size_t n = fill_foldcolumn(stcp->fold_text, wp, foldinfo, lnum); - stcp->fold_text[n] = NUL; - stcp->fold_attr = win_hl_attr(wp, use_cul ? HLF_CLF : HLF_FC); - } - } - // Make sure to clear->set->clear sign column for filler->first->wrapped lines - int i = 0; - for (; i < wp->w_scwidth; i++) { - SignTextAttrs *sattr = virtnum ? NULL : sign_get_attr(i, sattrs, wp->w_scwidth); - stcp->sign_text[i] = sattr && sattr->text ? sattr->text : " "; - stcp->sign_attr[i] = sattr ? (use_cul && sign_cul_attr ? sign_cul_attr : sattr->hl_attr_id) - : win_hl_attr(wp, use_cul ? HLF_CLS : HLF_SC); - } - stcp->sign_text[i] = NULL; + // When called for the first non-filler row of line "lnum" set num v:vars + long relnum = virtnum == 0 ? labs(get_cursor_rel_lnum(wp, lnum)) : -1; // When a buffer's line count has changed, make a best estimate for the full // width of the status column by building with "w_nrwidth_line_count". Add @@ -496,8 +469,7 @@ static void get_statuscol_display_info(statuscol_T *stcp, LineDrawState *draw_st if (stcp->textp + *n_extrap < stcp->text_end) { int hl = stcp->hlrecp->userhl; stcp->textp = stcp->hlrecp->start; - stcp->cur_attr = hl < 0 ? syn_id2attr(-stcp->hlrecp->userhl) - : hl > 0 ? hl : stcp->num_attr; + stcp->cur_attr = hl < 0 ? syn_id2attr(-hl) : hl > 0 ? hl : stcp->num_attr; stcp->hlrecp++; *draw_state = WL_STC - 1; } @@ -1208,7 +1180,13 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, if (*wp->w_p_stc != NUL) { // Draw the 'statuscolumn' if option is set. statuscol.draw = true; + statuscol.sattrs = sattrs; + statuscol.foldinfo = foldinfo; statuscol.width = win_col_off(wp); + statuscol.use_cul = use_cursor_line_sign(wp, lnum); + statuscol.sign_cul_attr = statuscol.use_cul ? sign_cul_attr : 0; + statuscol.num_attr = sign_num_attr ? sign_num_attr + : get_line_number_attr(wp, lnum, row, startrow, filler_lines); } int sign_idx = 0; @@ -1354,8 +1332,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, // Draw the 'statuscolumn' if option is set. if (statuscol.draw) { if (statuscol.textp == NULL) { - get_statuscol_str(wp, lnum, row, startrow, filler_lines, cul_attr, - sign_num_attr, sign_cul_attr, &statuscol, foldinfo, sattrs); + get_statuscol_str(wp, lnum, row - startrow - filler_lines, &statuscol); if (wp->w_redr_statuscol) { break; } |