]> granicus.if.org Git - vim/commitdiff
patch 8.0.0220: completion of highlight names misses a few values v8.0.0220
authorBram Moolenaar <Bram@vim.org>
Sun, 22 Jan 2017 18:25:33 +0000 (19:25 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 22 Jan 2017 18:25:33 +0000 (19:25 +0100)
Problem:    Completion for :match does not show "none" and other missing
            highlight names.
Solution:   Skip over cleared entries before checking the index to be at the
            end.

src/syntax.c
src/testdir/test_cmdline.vim
src/version.c

index d5c2e7712800d80b519c99349196252565fdbf31..dbadb70fde92259698337754bd5da9b880f45e32 100644 (file)
@@ -9956,6 +9956,13 @@ highlight_list_two(int cnt, int attr)
     char_u *
 get_highlight_name(expand_T *xp UNUSED, int idx)
 {
+    if (idx < 0)
+       return NULL;
+    /* Items are never removed from the table, skip the ones that were cleared.
+     */
+    while (idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
+       ++idx;
+
 #ifdef FEAT_CMDL_COMPL
     if (idx == highlight_ga.ga_len && include_none != 0)
        return (char_u *)"none";
@@ -9968,12 +9975,6 @@ get_highlight_name(expand_T *xp UNUSED, int idx)
                                                         && include_link != 0)
        return (char_u *)"clear";
 #endif
-    if (idx < 0)
-       return NULL;
-    /* Items are never removed from the table, skip the ones that were cleared.
-     */
-    while (idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared)
-       ++idx;
     if (idx >= highlight_ga.ga_len)
        return NULL;
     return HL_TABLE()[idx].sg_name;
index abeb609eaa24866011375e01d279694fe104e6cb..279a1681c4b600dff20ff3e48311852a162beb6d 100644 (file)
@@ -25,8 +25,34 @@ func Test_complete_wildmenu()
   set nowildmenu
 endfunc
 
+func Test_match_completion()
+  if !has('cmdline_compl')
+    return
+  endif
+  hi Aardig ctermfg=green
+  call feedkeys(":match \<Tab>\<Home>\"\<CR>", 'xt')
+  call assert_equal('"match Aardig', getreg(':'))
+  call feedkeys(":match \<S-Tab>\<Home>\"\<CR>", 'xt')
+  call assert_equal('"match none', getreg(':'))
+endfunc
+
+func Test_highlight_completion()
+  if !has('cmdline_compl')
+    return
+  endif
+  hi Aardig ctermfg=green
+  call feedkeys(":hi \<Tab>\<Home>\"\<CR>", 'xt')
+  call assert_equal('"hi Aardig', getreg(':'))
+  call feedkeys(":hi li\<S-Tab>\<Home>\"\<CR>", 'xt')
+  call assert_equal('"hi link', getreg(':'))
+  call feedkeys(":hi d\<S-Tab>\<Home>\"\<CR>", 'xt')
+  call assert_equal('"hi default', getreg(':'))
+  call feedkeys(":hi c\<S-Tab>\<Home>\"\<CR>", 'xt')
+  call assert_equal('"hi clear', getreg(':'))
+endfunc
+
 func Test_expr_completion()
-  if !(has('cmdline_compl') && has('eval'))
+  if !has('cmdline_compl')
     return
   endif
   for cmd in [
index 90f056b690ce6d9906b53ab4f6c0eebc9fbaa5c5..84cb94030c7cded2b984ae3259cff44cbcb0f242 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    220,
 /**/
     219,
 /**/