branch: elpa/go-mode
commit fa2162b6b34af0d2e8038940d8fa13e775a1cae6
Author: Muir Manders <[email protected]>
Commit: Peter Sanford <[email protected]>

    Fix "nil" fontification in type switch clause.
    
    Be sure to fontify "nil" as a constant instead of a type name.
    
    Closes: #326 [via git-merge-pr]
---
 go-mode.el                | 3 ++-
 test/go-font-lock-test.el | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/go-mode.el b/go-mode.el
index f567830..ac71cb6 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -1422,7 +1422,8 @@ comma, it stops at it. Return non-nil if comma was found."
     (while (and (not found-match) (not done))
       (when (looking-at (concat "[[:space:]\n]*" go-type-name-regexp 
"[[:space:]]*[,:]"))
         (goto-char (match-end 1))
-        (setq found-match t))
+        (unless (member (match-string 1) go-constants)
+          (setq found-match t)))
       (setq done (not (go--search-next-comma end))))
     found-match))
 
diff --git a/test/go-font-lock-test.el b/test/go-font-lock-test.el
index 2b858ea..6a8306f 100644
--- a/test/go-font-lock-test.el
+++ b/test/go-font-lock-test.el
@@ -76,6 +76,8 @@ KmapK[TstringT]KinterfaceK{}{
   (go--should-fontify "
 KswitchK foo.(KtypeK) {
 KcaseK TstringT, *Tfoo.ZebraT, [2]TbyteT:
+KcaseK CnilC:
+KdefaultK:
 }")
 
   (go--should-fontify "

Reply via email to