Mercurial > vim
diff src/drawline.c @ 26266:365e7f083f02 v8.2.3664
patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Commit: https://github.com/vim/vim/commit/e413ea04b716effb28eb49dbc98ad3f9f761545a
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Nov 24 16:20:13 2021 +0000
patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Problem: Cannot adjust sign highlighting for 'cursorline'.
Solution: Add CursorLineSign and CursorLineFold highlight groups.
(Gregory Anders, closes #9201)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 24 Nov 2021 17:30:06 +0100 |
parents | 373278f5bd51 |
children | baec4e1cee43 |
line wrap: on
line diff
--- a/src/drawline.c +++ b/src/drawline.c @@ -77,6 +77,17 @@ margin_columns_win(win_T *wp, int *left_ #ifdef FEAT_SIGNS /* + * Return TRUE if CursorLineSign highlight is to be used. + */ + static int +use_cursor_line_sign(win_T *wp, linenr_T lnum) +{ + return wp->w_p_cul + && lnum == wp->w_cursor.lnum + && (wp->w_p_culopt_flags & CULOPT_NBR); +} + +/* * Get information needed to display the sign in line 'lnum' in window 'wp'. * If 'nrcol' is TRUE, the sign is going to be displayed in the number column. * Otherwise the sign is going to be displayed in the sign column. @@ -85,7 +96,7 @@ margin_columns_win(win_T *wp, int *left_ get_sign_display_info( int nrcol, win_T *wp, - linenr_T lnum UNUSED, + linenr_T lnum, sign_attrs_T *sattr, int wcr_attr, int row, @@ -111,7 +122,10 @@ get_sign_display_info( *n_extrap = number_width(wp) + 1; else { - *char_attrp = hl_combine_attr(wcr_attr, HL_ATTR(HLF_SC)); + if (use_cursor_line_sign(wp, lnum)) + *char_attrp = hl_combine_attr(wcr_attr, HL_ATTR(HLF_CLS)); + else + *char_attrp = hl_combine_attr(wcr_attr, HL_ATTR(HLF_SC)); *n_extrap = 2; } @@ -176,7 +190,11 @@ get_sign_display_info( *c_finalp = NUL; *n_extrap = (int)STRLEN(*pp_extra); } - *char_attrp = sattr->sat_texthl; + + if (use_cursor_line_sign(wp, lnum) && sattr->sat_culhl > 0) + *char_attrp = sattr->sat_culhl; + else + *char_attrp = sattr->sat_texthl; } } } @@ -1051,7 +1069,12 @@ win_line( p_extra = p_extra_free; c_extra = NUL; c_final = NUL; - char_attr = hl_combine_attr(wcr_attr, HL_ATTR(HLF_FC)); + if (use_cursor_line_sign(wp, lnum)) + char_attr = + hl_combine_attr(wcr_attr, HL_ATTR(HLF_CLF)); + else + char_attr = + hl_combine_attr(wcr_attr, HL_ATTR(HLF_FC)); } } }