diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-10-31 20:24:24 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-11-27 01:14:55 +0100 |
commit | 60f845ca55a1b8b11a4eb390b1fed93a79e99ad5 (patch) | |
tree | 011aab33314cde1e96a07b7453606e457c431c5f | |
parent | 3283db4ecbe32c6f2bbf1c7ea3032ef4091d5444 (diff) | |
download | rneovim-60f845ca55a1b8b11a4eb390b1fed93a79e99ad5.tar.gz rneovim-60f845ca55a1b8b11a4eb390b1fed93a79e99ad5.tar.bz2 rneovim-60f845ca55a1b8b11a4eb390b1fed93a79e99ad5.zip |
diff/highlight: Show underline for low-priority CursorLine
-rw-r--r-- | src/nvim/highlight.c | 18 | ||||
-rw-r--r-- | src/nvim/screen.c | 10 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 32 |
3 files changed, 57 insertions, 3 deletions
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index ae2b90d8a1..89a41e73de 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -177,6 +177,24 @@ void update_window_hl(win_T *wp, bool invalid) } } +/// Gets HL_UNDERLINE highlight. +int hl_get_underline(void) +{ + return get_attr_entry((HlEntry){ + .attr = (HlAttrs){ + .cterm_ae_attr = (int16_t)HL_UNDERLINE, + .cterm_fg_color = 0, + .cterm_bg_color = 0, + .rgb_ae_attr = (int16_t)HL_UNDERLINE, + .rgb_fg_color = 0, + .rgb_bg_color = 0, + }, + .kind = kHlUI, + .id1 = 0, + .id2 = 0, + }); +} + /// Get attribute code for forwarded :terminal highlights. int hl_get_term_attr(HlAttrs *aep) { diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 2a1dae1767..eb24e2af1c 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -3052,9 +3052,13 @@ win_line ( diff_hlf = HLF_CHD; // changed line } line_attr = win_hl_attr(wp, diff_hlf); - // Overlay CursorLine onto diff highlight, unless it's low-priority. - if (!line_attr_lowprio && wp->w_p_cul && lnum == wp->w_cursor.lnum) { - line_attr = hl_combine_attr(line_attr, win_hl_attr(wp, HLF_CUL)); + // Overlay CursorLine onto diff-mode highlight. + if (wp->w_p_cul && lnum == wp->w_cursor.lnum) { + line_attr = 0 != line_attr_lowprio // Low-priority CursorLine + ? hl_combine_attr(hl_combine_attr(win_hl_attr(wp, HLF_CUL), + line_attr), + hl_get_underline()) + : hl_combine_attr(line_attr, win_hl_attr(wp, HLF_CUL)); } } diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 55fc343e4c..dffe5b5197 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -768,6 +768,38 @@ describe('CursorLine highlight', function() {4:[No Name] [+] }{9:[No Name] [+] }| | ]]) + + -- CursorLine with fg=NONE is "low-priority". + -- Rendered as underline in a diff-line. #9028 + command('hi CursorLine ctermbg=red ctermfg=NONE guibg=red guifg=NONE') + feed('kkkk') + screen:expect([[ + {1: }line 1 some text {4:│}{1: }line 1 some text | + {1: }{11:line 2 mo}{12:Re text!}{11: }{4:│}{1: }{11:^line 2 mo}{12:re text}{11: }| + {1: }{5:extra line! }{4:│}{1: }{6:----------------------}| + {1: }extra line! {4:│}{1: }extra line! | + {1: }extra line! {4:│}{1: }extra line! | + {1: }last line ... {4:│}{1: }last line ... | + {1: } {4:│}{1: } | + {1: }{8:~ }{4:│}{1: }{8:~ }| + {1: }{8:~ }{4:│}{1: }{8:~ }| + {1: }{8:~ }{4:│}{1: }{8:~ }| + {4:[No Name] [+] }{9:[No Name] [+] }| + | + ]], { + [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, + [2] = {bold = true, background = Screen.colors.Red}, + [3] = {background = Screen.colors.LightMagenta}, + [4] = {reverse = true}, + [5] = {background = Screen.colors.LightBlue}, + [6] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1}, + [7] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, + [8] = {bold = true, foreground = Screen.colors.Blue1}, + [9] = {bold = true, reverse = true}, + [10] = {bold = true}, + [11] = {special = Screen.colors.Grey0, underline = true, foreground = Screen.colors.Grey0, background = Screen.colors.Grey0}, + [12] = {bold = true, special = Screen.colors.Grey0, background = Screen.colors.Grey0, foreground = Screen.colors.Grey0, underline = true}, + }) end) end) |