patch 8.0.0513: getting name of cleared highlight group is wrong

Problem:    Getting name of cleared highlight group is wrong. (Matt Wozniski)
Solution:   Only skip over cleared names for completion. (closes #1592)
            Also fix that a cleared group causes duplicate completions.
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 98a4337..77c9170 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -71,6 +71,14 @@
   call assert_equal('"hi default', getreg(':'))
   call feedkeys(":hi c\<S-Tab>\<Home>\"\<CR>", 'xt')
   call assert_equal('"hi clear', getreg(':'))
+
+  " A cleared group does not show up in completions.
+  hi Anders ctermfg=green
+  call assert_equal(['Aardig', 'Anders'], getcompletion('A', 'highlight'))
+  hi clear Aardig
+  call assert_equal(['Anders'], getcompletion('A', 'highlight'))
+  hi clear Anders
+  call assert_equal([], getcompletion('A', 'highlight'))
 endfunc
 
 func Test_expr_completion()
diff --git a/src/testdir/test_syntax.vim b/src/testdir/test_syntax.vim
index 8a00f99..9ebe3f1 100644
--- a/src/testdir/test_syntax.vim
+++ b/src/testdir/test_syntax.vim
@@ -326,13 +326,16 @@
   syntax keyword Bar tar
   call assert_match('Foo', execute('syntax'))
   call assert_match('Bar', execute('syntax'))
+  call assert_equal('Foo', synIDattr(hlID("Foo"), "name"))
   syn clear Foo
   call assert_notmatch('Foo', execute('syntax'))
   call assert_match('Bar', execute('syntax'))
+  call assert_equal('Foo', synIDattr(hlID("Foo"), "name"))
   syn clear Foo Bar
   call assert_notmatch('Foo', execute('syntax'))
   call assert_notmatch('Bar', execute('syntax'))
   hi clear Foo
+  call assert_equal('Foo', synIDattr(hlID("Foo"), "name"))
   hi clear Bar
 endfunc