diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-09-15 07:17:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-15 07:17:13 +0800 |
commit | 9ec0ecb222a0454c2afaf1afae72fe1ad7ccb2c8 (patch) | |
tree | 4da41861183de987bca26fb4698c2f45fa745e10 | |
parent | 2e92065686f62851318150a315591c30b8306a4b (diff) | |
download | rneovim-9ec0ecb222a0454c2afaf1afae72fe1ad7ccb2c8.tar.gz rneovim-9ec0ecb222a0454c2afaf1afae72fe1ad7ccb2c8.tar.bz2 rneovim-9ec0ecb222a0454c2afaf1afae72fe1ad7ccb2c8.zip |
refactor(drawline): remove unnecessary inline virt checks (#25163)
-rw-r--r-- | src/nvim/drawline.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index 969021ef2c..d0e31b41c3 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -136,8 +136,6 @@ typedef struct { ///< or w_skipcol or concealing int skipped_cells; ///< nr of skipped cells for virtual text ///< to be added to wlv.vcol later - bool more_virt_inline_chunks; ///< indicates if there is more inline virtual text - ///< after n_extra } winlinevars_T; /// for line_putchar. Contains the state that needs to be remembered from @@ -868,10 +866,12 @@ static void apply_cursorline_highlight(win_T *wp, winlinevars_T *wlv) } } -/// Checks if there is more inline virtual text that need to be drawn -/// and sets has_more_virt_inline_chunks to reflect that. +/// Checks if there is more inline virtual text that need to be drawn. static bool has_more_inline_virt(winlinevars_T *wlv, ptrdiff_t v) { + if (wlv->virt_inline_i < kv_size(wlv->virt_inline)) { + return true; + } DecorState *state = &decor_state; for (size_t i = 0; i < kv_size(state->active); i++) { DecorRange *item = &kv_A(state->active, i); @@ -911,7 +911,6 @@ static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t break; } } - wlv->more_virt_inline_chunks = has_more_inline_virt(wlv, v); if (!kv_size(wlv->virt_inline)) { // no more inline virtual text here break; @@ -929,11 +928,6 @@ static void handle_inline_virtual_text(win_T *wp, winlinevars_T *wlv, ptrdiff_t wlv->c_final = NUL; wlv->extra_attr = vtc.hl_id ? syn_id2attr(vtc.hl_id) : 0; wlv->n_attr = mb_charlen(vtc.text); - - // Checks if there is more inline virtual text chunks that need to be drawn. - wlv->more_virt_inline_chunks = has_more_inline_virt(wlv, v) - || wlv->virt_inline_i < kv_size(wlv->virt_inline); - // If the text didn't reach until the first window // column we need to skip cells. if (wlv->skip_cells > 0) { @@ -2890,15 +2884,14 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl && wlv.filler_todo <= 0 && (wp->w_p_rl ? wlv.col == 0 : wlv.col == grid->cols - 1) && !has_fold) { - if (*ptr == NUL && lcs_eol_one == 0 && has_decor) { + if (has_decor && *ptr == NUL && lcs_eol_one == 0) { // Tricky: there might be a virtual text just _after_ the last char decor_redraw_col(wp, (colnr_T)v, wlv.off, false, &decor_state); - handle_inline_virtual_text(wp, &wlv, v); } if (*ptr != NUL || lcs_eol_one > 0 || (wlv.n_extra > 0 && (wlv.c_extra != NUL || *wlv.p_extra != NUL)) - || wlv.more_virt_inline_chunks) { + || has_more_inline_virt(&wlv, v)) { c = wp->w_p_lcs_chars.ext; wlv.char_attr = win_hl_attr(wp, HLF_AT); mb_c = c; @@ -3085,13 +3078,12 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl wlv.char_attr = saved_attr2; } - if ((wp->w_p_rl ? (wlv.col < 0) : (wlv.col >= grid->cols)) && has_decor) { + if (has_decor && (wp->w_p_rl ? (wlv.col < 0) : (wlv.col >= grid->cols))) { // At the end of screen line: might need to peek for decorations just after - // this position. Without wrapping, we might need to display win_pos overlays + // this position. Without wrapping, we might need to display win_col overlays // from the entire text line. colnr_T nextpos = wp->w_p_wrap ? (colnr_T)(ptr - line) : (colnr_T)strlen(line); decor_redraw_col(wp, nextpos, wlv.off, true, &decor_state); - handle_inline_virtual_text(wp, &wlv, v); } // At end of screen line and there is more to come: Display the line @@ -3104,7 +3096,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl || (wp->w_p_list && wp->w_p_lcs_chars.eol != NUL && wlv.p_extra != at_end_str) || (wlv.n_extra != 0 && (wlv.c_extra != NUL || *wlv.p_extra != NUL)) - || wlv.more_virt_inline_chunks)) { + || has_more_inline_virt(&wlv, v))) { bool wrap = wp->w_p_wrap // Wrapping enabled. && wlv.filler_todo <= 0 // Not drawing diff filler lines. && lcs_eol_one != -1 // Haven't printed the lcs_eol character. |