patch 9.1.0936: cannot highlight completed text
Problem: cannot highlight completed text
Solution: (optionally) highlight auto-completed text using the
ComplMatchIns highlight group (glepnir)
closes: #16173
Signed-off-by: glepnir <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/drawline.c b/src/drawline.c
index b49e653..ec91331 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -1139,6 +1139,7 @@
long vcol_prev = -1; // "wlv.vcol" of previous character
char_u *line; // current line
char_u *ptr; // current position in "line"
+ int in_curline = wp == curwin && lnum == curwin->w_cursor.lnum;
#ifdef FEAT_PROP_POPUP
char_u *p_extra_free2 = NULL; // another p_extra to be freed
@@ -1172,6 +1173,7 @@
// highlighting
int area_attr = 0; // attributes desired by highlighting
int search_attr = 0; // attributes desired by 'hlsearch'
+ int ins_match_attr = 0; // attributes desired by PmenuMatch
#ifdef FEAT_SYN_HL
int vcol_save_attr = 0; // saved attr for 'cursorcolumn'
int syntax_attr = 0; // attributes desired by syntax
@@ -1415,8 +1417,7 @@
}
// Check if the character under the cursor should not be inverted
- if (!highlight_match && lnum == curwin->w_cursor.lnum
- && wp == curwin
+ if (!highlight_match && in_curline
#ifdef FEAT_GUI
&& !gui.in_use
#endif
@@ -3939,6 +3940,14 @@
if (wlv.draw_state == WL_LINE)
vcol_prev = wlv.vcol;
+ if (wlv.draw_state == WL_LINE
+ && (State & MODE_INSERT) && in_curline && ins_compl_active())
+ {
+ ins_match_attr = ins_compl_col_range_attr(wlv.col);
+ if (ins_match_attr > 0)
+ wlv.char_attr = hl_combine_attr(wlv.char_attr, ins_match_attr);
+ }
+
// Store character to be displayed.
// Skip characters that are left of the screen for 'nowrap'.
if (wlv.draw_state < WL_LINE || skip_cells <= 0)