Merge commit 'refs/pull/upstream/5156'

This commit is contained in:
Justin M. Keyes
2016-08-22 02:47:10 -04:00
8 changed files with 278 additions and 66 deletions

View File

@@ -4883,6 +4883,10 @@ PmenuSbar Popup menu: scrollbar.
PmenuThumb Popup menu: Thumb of the scrollbar. PmenuThumb Popup menu: Thumb of the scrollbar.
*hl-Question* *hl-Question*
Question |hit-enter| prompt and yes/no questions Question |hit-enter| prompt and yes/no questions
*hl-QuickFixLine*
QuickFixLine The selected |quickfix| item in the quickfix window.
|hl-CursorLine| is combined with this when the cursor is on
the currently selected quickfix item.
*hl-Search* *hl-Search*
Search Last search pattern highlighting (see 'hlsearch'). Search Last search pattern highlighting (see 'hlsearch').
Also used for highlighting the current line in the quickfix Also used for highlighting the current line in the quickfix

View File

@@ -53,7 +53,7 @@ syn keyword vimGroup contained Comment Constant String Character Number Boolean
syn keyword vimHLGroup contained ColorColumn Cursor CursorColumn CursorIM CursorLine CursorLineNr DiffAdd DiffChange DiffDelete DiffText Directory ErrorMsg FoldColumn Folded IncSearch LineNr MatchParen Menu ModeMsg MoreMsg NonText Normal Pmenu PmenuSbar PmenuSel PmenuThumb Question Scrollbar Search SignColumn SpecialKey SpellBad SpellCap SpellLocal SpellRare StatusLine StatusLineNC TabLine TabLineFill TabLineSel Title Tooltip VertSplit Visual WarningMsg WildMenu syn keyword vimHLGroup contained ColorColumn Cursor CursorColumn CursorIM CursorLine CursorLineNr DiffAdd DiffChange DiffDelete DiffText Directory ErrorMsg FoldColumn Folded IncSearch LineNr MatchParen Menu ModeMsg MoreMsg NonText Normal Pmenu PmenuSbar PmenuSel PmenuThumb Question Scrollbar Search SignColumn SpecialKey SpellBad SpellCap SpellLocal SpellRare StatusLine StatusLineNC TabLine TabLineFill TabLineSel Title Tooltip VertSplit Visual WarningMsg WildMenu
syn match vimHLGroup contained "Conceal" syn match vimHLGroup contained "Conceal"
syn keyword vimOnlyHLGroup contained VisualNOS syn keyword vimOnlyHLGroup contained VisualNOS
syn keyword nvimHLGroup contained EndOfBuffer TermCursor TermCursorNC syn keyword nvimHLGroup contained EndOfBuffer TermCursor TermCursorNC QuickFixLine
"}}}2 "}}}2
syn case match syn case match
" Special Vim Highlighting (not automatic) {{{1 " Special Vim Highlighting (not automatic) {{{1

View File

@@ -442,59 +442,60 @@ EXTERN int no_check_timestamps INIT(= 0); /* Don't check timestamps */
typedef enum { typedef enum {
HLF_8 = 0 /* Meta & special keys listed with ":map", text that is HLF_8 = 0 /* Meta & special keys listed with ":map", text that is
displayed different from what it is */ displayed different from what it is */
, HLF_EOB //< after the last line in the buffer , HLF_EOB // after the last line in the buffer
, HLF_TERM //< terminal cursor focused , HLF_TERM // terminal cursor focused
, HLF_TERMNC //< terminal cursor unfocused , HLF_TERMNC // terminal cursor unfocused
, HLF_AT /* @ characters at end of screen, characters that , HLF_AT // @ characters at end of screen, characters that
don't really exist in the text */ // don't really exist in the text
, HLF_D /* directories in CTRL-D listing */ , HLF_D // directories in CTRL-D listing
, HLF_E /* error messages */ , HLF_E // error messages
, HLF_I /* incremental search */ , HLF_I // incremental search
, HLF_L /* last search string */ , HLF_L // last search string
, HLF_M /* "--More--" message */ , HLF_M // "--More--" message
, HLF_CM /* Mode (e.g., "-- INSERT --") */ , HLF_CM // Mode (e.g., "-- INSERT --")
, HLF_N /* line number for ":number" and ":#" commands */ , HLF_N // line number for ":number" and ":#" commands
, HLF_CLN /* current line number */ , HLF_CLN // current line number
, HLF_R /* return to continue message and yes/no questions */ , HLF_R // return to continue message and yes/no questions
, HLF_S /* status lines */ , HLF_S // status lines
, HLF_SNC /* status lines of not-current windows */ , HLF_SNC // status lines of not-current windows
, HLF_C /* column to separate vertically split windows */ , HLF_C // column to separate vertically split windows
, HLF_T /* Titles for output from ":set all", ":autocmd" etc. */ , HLF_T // Titles for output from ":set all", ":autocmd" etc.
, HLF_V /* Visual mode */ , HLF_V // Visual mode
, HLF_VNC /* Visual mode, autoselecting and not clipboard owner */ , HLF_VNC // Visual mode, autoselecting and not clipboard owner
, HLF_W /* warning messages */ , HLF_W // warning messages
, HLF_WM /* Wildmenu highlight */ , HLF_WM // Wildmenu highlight
, HLF_FL /* Folded line */ , HLF_FL // Folded line
, HLF_FC /* Fold column */ , HLF_FC // Fold column
, HLF_ADD /* Added diff line */ , HLF_ADD // Added diff line
, HLF_CHD /* Changed diff line */ , HLF_CHD // Changed diff line
, HLF_DED /* Deleted diff line */ , HLF_DED // Deleted diff line
, HLF_TXD /* Text Changed in diff line */ , HLF_TXD // Text Changed in diff line
, HLF_CONCEAL /* Concealed text */ , HLF_CONCEAL // Concealed text
, HLF_SC /* Sign column */ , HLF_SC // Sign column
, HLF_SPB /* SpellBad */ , HLF_SPB // SpellBad
, HLF_SPC /* SpellCap */ , HLF_SPC // SpellCap
, HLF_SPR /* SpellRare */ , HLF_SPR // SpellRare
, HLF_SPL /* SpellLocal */ , HLF_SPL // SpellLocal
, HLF_PNI /* popup menu normal item */ , HLF_PNI // popup menu normal item
, HLF_PSI /* popup menu selected item */ , HLF_PSI // popup menu selected item
, HLF_PSB /* popup menu scrollbar */ , HLF_PSB // popup menu scrollbar
, HLF_PST /* popup menu scrollbar thumb */ , HLF_PST // popup menu scrollbar thumb
, HLF_TP /* tabpage line */ , HLF_TP // tabpage line
, HLF_TPS /* tabpage line selected */ , HLF_TPS // tabpage line selected
, HLF_TPF /* tabpage line filler */ , HLF_TPF // tabpage line filler
, HLF_CUC /* 'cursurcolumn' */ , HLF_CUC // 'cursurcolumn'
, HLF_CUL /* 'cursurline' */ , HLF_CUL // 'cursurline'
, HLF_MC /* 'colorcolumn' */ , HLF_MC // 'colorcolumn'
, HLF_COUNT /* MUST be the last one */ , HLF_QFL // selected quickfix line
, HLF_COUNT // MUST be the last one
} hlf_T; } hlf_T;
/* The HL_FLAGS must be in the same order as the HLF_ enums! /* The HL_FLAGS must be in the same order as the HLF_ enums!
* When changing this also adjust the default for 'highlight'. */ * When changing this also adjust the default for 'highlight'. */
#define HL_FLAGS {'8', '~', 'z', 'Z', '@', 'd', 'e', 'i', 'l', 'm', 'M', 'n', \ #define HL_FLAGS { '8', '~', 'z', 'Z', '@', 'd', 'e', 'i', 'l', 'm', 'M', 'n', \
'N', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', 'f', 'F', \ 'N', 'r', 's', 'S', 'c', 't', 'v', 'V', 'w', 'W', 'f', 'F', \
'A', 'C', 'D', 'T', '-', '>', 'B', 'P', 'R', 'L', '+', '=', \ 'A', 'C', 'D', 'T', '-', '>', 'B', 'P', 'R', 'L', '+', '=', \
'x', 'X', '*', '#', '_', '!', '.', 'o'} 'x', 'X', '*', '#', '_', '!', '.', 'o', 'q' }
EXTERN int highlight_attr[HLF_COUNT]; /* Highl. attr for each context. */ EXTERN int highlight_attr[HLF_COUNT]; /* Highl. attr for each context. */
EXTERN int highlight_user[9]; /* User[1-9] attributes */ EXTERN int highlight_user[9]; /* User[1-9] attributes */

View File

@@ -246,7 +246,7 @@ typedef struct vimoption {
"A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal," \ "A:DiffAdd,C:DiffChange,D:DiffDelete,T:DiffText,>:SignColumn,-:Conceal," \
"B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel," \ "B:SpellBad,P:SpellCap,R:SpellRare,L:SpellLocal,+:Pmenu,=:PmenuSel," \
"x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill," \ "x:PmenuSbar,X:PmenuThumb,*:TabLine,#:TabLineSel,_:TabLineFill," \
"!:CursorColumn,.:CursorLine,o:ColorColumn" "!:CursorColumn,.:CursorLine,o:ColorColumn,q:QuickFixLine"
/* /*
* options[] is initialized here. * options[] is initialized here.

View File

@@ -1764,15 +1764,17 @@ void qf_list(exarg_T *eap)
vim_snprintf((char *)IObuff, IOSIZE, "%2d %s", vim_snprintf((char *)IObuff, IOSIZE, "%2d %s",
i, (char *)fname); i, (char *)fname);
msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index msg_outtrans_attr(IObuff, i == qi->qf_lists[qi->qf_curlist].qf_index
? hl_attr(HLF_L) : hl_attr(HLF_D)); ? hl_attr(HLF_QFL) : hl_attr(HLF_D));
if (qfp->qf_lnum == 0) if (qfp->qf_lnum == 0) {
IObuff[0] = NUL; IObuff[0] = NUL;
else if (qfp->qf_col == 0) } else if (qfp->qf_col == 0) {
sprintf((char *)IObuff, ":%" PRId64, (int64_t)qfp->qf_lnum); vim_snprintf((char *)IObuff, IOSIZE, ":%" PRId64,
else (int64_t)qfp->qf_lnum);
sprintf((char *)IObuff, ":%" PRId64 " col %d", } else {
vim_snprintf((char *)IObuff, IOSIZE, ":%" PRId64 " col %d",
(int64_t)qfp->qf_lnum, qfp->qf_col); (int64_t)qfp->qf_lnum, qfp->qf_col);
sprintf((char *)IObuff + STRLEN(IObuff), "%s:", }
vim_snprintf((char *)IObuff + STRLEN(IObuff), IOSIZE, "%s:",
(char *)qf_types(qfp->qf_type, qfp->qf_nr)); (char *)qf_types(qfp->qf_type, qfp->qf_nr));
msg_puts_attr(IObuff, hl_attr(HLF_N)); msg_puts_attr(IObuff, hl_attr(HLF_N));
if (qfp->qf_pattern != NULL) { if (qfp->qf_pattern != NULL) {

View File

@@ -2403,11 +2403,14 @@ win_line (
if (v != 0) if (v != 0)
line_attr = sign_get_attr((int)v, TRUE); line_attr = sign_get_attr((int)v, TRUE);
/* Highlight the current line in the quickfix window. */ // Highlight the current line in the quickfix window.
if (bt_quickfix(wp->w_buffer) && qf_current_entry(wp) == lnum) if (bt_quickfix(wp->w_buffer) && qf_current_entry(wp) == lnum) {
line_attr = hl_attr(HLF_L); line_attr = hl_attr(HLF_QFL);
if (line_attr != 0) }
area_highlighting = TRUE;
if (line_attr != 0) {
area_highlighting = true;
}
line = ml_get_buf(wp->w_buffer, lnum, FALSE); line = ml_get_buf(wp->w_buffer, lnum, FALSE);
ptr = line; ptr = line;
@@ -2624,7 +2627,12 @@ win_line (
* then. */ * then. */
if (wp->w_p_cul && lnum == wp->w_cursor.lnum if (wp->w_p_cul && lnum == wp->w_cursor.lnum
&& !(wp == curwin && VIsual_active)) { && !(wp == curwin && VIsual_active)) {
if (line_attr != 0 && !(State & INSERT) && bt_quickfix(wp->w_buffer)
&& qf_current_entry(wp) == lnum) {
line_attr = hl_combine_attr(hl_attr(HLF_CUL), line_attr);
} else {
line_attr = hl_attr(HLF_CUL); line_attr = hl_attr(HLF_CUL);
}
area_highlighting = true; area_highlighting = true;
} }

View File

@@ -5902,6 +5902,7 @@ static char *highlight_init_both[] =
"VertSplit cterm=reverse gui=reverse", "VertSplit cterm=reverse gui=reverse",
"WildMenu ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black", "WildMenu ctermbg=Yellow ctermfg=Black guibg=Yellow guifg=Black",
"default link EndOfBuffer NonText", "default link EndOfBuffer NonText",
"default link QuickFixLine Search",
NULL NULL
}; };

View File

@@ -0,0 +1,196 @@
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths
local insert, execute = helpers.insert, helpers.execute
describe('quickfix selection highlight', function()
local screen
before_each(function()
clear()
screen = Screen.new(25, 10)
screen:attach()
screen:set_default_attr_ids({
[1] = { bold = true, foreground = Screen.colors.Blue },
[2] = {reverse = true},
[3] = {foreground = Screen.colors.Brown},
[4] = {bold = true, reverse = true},
[5] = {background = Screen.colors.Green},
[6] = {foreground = Screen.colors.Brown, background = Screen.colors.Green},
[7] = {background = Screen.colors.Red},
[8] = {foreground = Screen.colors.Brown, background = Screen.colors.Red},
[9] = {background = Screen.colors.Fuchsia},
[10] = {foreground = Screen.colors.Red, background = Screen.colors.Fuchsia},
[11] = {foreground = Screen.colors.Red},
[12] = {foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia},
})
meths.set_option('errorformat', '%m %l')
execute('syntax on')
execute('highlight Search guibg=Green')
insert([[
Line 1
Line 2
Line 3
Line 4
Line 5
]])
execute('cad')
feed('gg')
screen:expect([[
^Line 1 |
Line 2 |
Line 3 |
Line 4 |
Line 5 |
|
{1:~ }|
{1:~ }|
{1:~ }|
:cad |
]])
end)
it('using default Search highlight group', function()
execute('copen')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
{5:^|}{6:1}{5:| Line }|
|{3:2}| Line |
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:copen |
]])
execute('cnext')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
|{3:1}| Line |
{5:^|}{6:2}{5:| Line }|
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:cnext |
]])
end)
it('using QuickFixLine highlight group', function()
execute('highlight QuickFixLine guibg=Red')
execute('copen')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
{7:^|}{8:1}{7:| Line }|
|{3:2}| Line |
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:copen |
]])
execute('cnext')
screen:expect([[
Line 1 |
{2:[No Name] [+] }|
|{3:1}| Line |
{7:^|}{8:2}{7:| Line }|
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:cnext |
]])
end)
it('combines with CursorLine', function()
execute('set cursorline')
execute('highlight QuickFixLine guifg=Red')
execute('highlight CursorLine guibg=Fuchsia')
execute('copen')
screen:expect([[
{9:Line 1 }|
{2:[No Name] [+] }|
{10:^|1| Line }|
|{3:2}| Line |
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:copen |
]])
feed('j')
screen:expect([[
{9:Line 1 }|
{2:[No Name] [+] }|
{11:|1| Line }|
{9:^|}{12:2}{9:| Line }|
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:copen |
]])
end)
it('QuickFixLine background takes precedence over CursorLine', function()
execute('set cursorline')
execute('highlight QuickFixLine guibg=Red')
execute('highlight CursorLine guibg=Fuchsia')
execute('copen')
screen:expect([[
{9:Line 1 }|
{2:[No Name] [+] }|
{7:^|}{8:1}{7:| Line }|
|{3:2}| Line |
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:copen |
]])
feed('j')
screen:expect([[
{9:Line 1 }|
{2:[No Name] [+] }|
{7:|}{8:1}{7:| Line }|
{9:^|}{12:2}{9:| Line }|
|{3:3}| Line |
|{3:4}| Line |
|{3:5}| Line |
|| |
{4:[Quickfix List] }|
:copen |
]])
end)
end)