diff options
Diffstat (limited to 'src/nvim/drawline.c')
-rw-r--r-- | src/nvim/drawline.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index d0cd11ccf3..d0142c6efa 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -106,7 +106,7 @@ typedef struct { int c_extra; ///< extra chars, all the same int c_final; ///< final char, mandatory if set - bool extra_for_extmark; + bool extra_for_extmark; ///< n_extra set for inline virtual text // saved "extra" items for when draw_state becomes WL_LINE (again) int saved_n_extra; @@ -1147,8 +1147,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl char buf_fold[FOLD_TEXT_LEN]; // Hold value returned by get_foldtext - bool area_active = false; - // 'cursorlineopt' has "screenline" and cursor is in this line bool cul_screenline = false; // margin columns for the screen line, needed for when 'cursorlineopt' @@ -1786,32 +1784,14 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl int extmark_attr = 0; if (wlv.draw_state == WL_LINE && (area_highlighting || spv->spv_has_spell || extra_check)) { - // handle Visual or match highlighting in this line - if (wlv.vcol == wlv.fromcol - || (wlv.vcol + 1 == wlv.fromcol - && ((wlv.n_extra == 0 && utf_ptr2cells(ptr) > 1) - || (wlv.n_extra > 0 && wlv.p_extra != NULL - && utf_ptr2cells(wlv.p_extra) > 1))) - || (vcol_prev == fromcol_prev - && vcol_prev < wlv.vcol // not at margin - && wlv.vcol < wlv.tocol)) { - area_attr = vi_attr; // start highlighting - if (area_highlighting) { - area_active = true; - } - } else if (area_attr != 0 && (wlv.vcol == wlv.tocol - || (noinvcur && wlv.vcol == wp->w_virtcol))) { - area_attr = 0; // stop highlighting - area_active = false; - } - if (wlv.n_extra == 0 || !wlv.extra_for_extmark) { wlv.reset_extra_attr = false; } if (has_decor && wlv.n_extra == 0) { - bool selected = (area_active || (area_highlighting && noinvcur - && wlv.vcol == wp->w_virtcol)); + bool selected = (area_highlighting + && ((wlv.vcol >= wlv.fromcol && wlv.vcol < wlv.tocol) + || (noinvcur && wlv.vcol == wp->w_virtcol))); extmark_attr = decor_redraw_col(wp, (colnr_T)v, wlv.off, selected, &decor_state); if (!has_fold && wp->w_buffer->b_virt_text_inline > 0) { @@ -1827,11 +1807,33 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl area_attr = 0; decor_attr = 0; search_attr_from_match = false; + } + if (wlv.n_extra > 0) { n_skip = 0; } } } + int *area_attr_p + = wlv.extra_for_extmark && wlv.virt_inline_hl_mode <= kHlModeReplace + ? &saved_area_attr : &area_attr; + + // handle Visual or match highlighting in this line + if (wlv.vcol == wlv.fromcol + || (wlv.vcol + 1 == wlv.fromcol + && ((wlv.n_extra == 0 && utf_ptr2cells(ptr) > 1) + || (wlv.n_extra > 0 && wlv.p_extra != NULL + && utf_ptr2cells(wlv.p_extra) > 1))) + || (vcol_prev == fromcol_prev + && vcol_prev < wlv.vcol // not at margin + && wlv.vcol < wlv.tocol)) { + *area_attr_p = vi_attr; // start highlighting + } else if (*area_attr_p != 0 + && (wlv.vcol == wlv.tocol + || (noinvcur && wlv.vcol == wp->w_virtcol))) { + *area_attr_p = 0; // stop highlighting + } + if (!has_fold && wlv.n_extra == 0) { // Check for start/end of 'hlsearch' and other matches. // After end, check for start/end of next match. |