@@ -410,6 +410,20 @@ For mode=set, all covered lines will have this weight."
410
410
(defvar go--default-face 'default
411
411
" A variable to refer to `default' face for use in font lock rules." )
412
412
413
+ (defun go--fontify-type-switch-case-pre ()
414
+ " Move point to line following the end of case statement.
415
+
416
+ This is used as an anchored font lock keyword PRE-MATCH-FORM. We
417
+ expand the font lock region to include multiline type switch case
418
+ statements."
419
+ (save-excursion
420
+ (beginning-of-line )
421
+ (while (or (looking-at " [[:space:]]*\\ ($\\ |//\\ )" ) (go--line-suffix-p " ," ))
422
+ (forward-line ))
423
+ (when (go--line-suffix-p " :" )
424
+ (forward-line ))
425
+ (point )))
426
+
413
427
(defun go--build-font-lock-keywords ()
414
428
; ; we cannot use 'symbols in regexp-opt because GNU Emacs <24
415
429
; ; doesn't understand that
@@ -440,7 +454,11 @@ For mode=set, all covered lines will have this weight."
440
454
(go--match-ident-type-pair 2 font-lock-type-face )
441
455
442
456
; ; An anchored matcher for type switch case clauses.
443
- (go--match-type-switch-case (go--fontify-type-switch-case nil nil (1 font-lock-type-face )))
457
+ (go--match-type-switch-case
458
+ (go--fontify-type-switch-case
459
+ (go--fontify-type-switch-case-pre)
460
+ nil
461
+ (1 font-lock-type-face )))
444
462
445
463
; ; Match variable names in var decls, constant names in const
446
464
; ; decls, and type names in type decls.
@@ -1467,7 +1485,7 @@ comma, it stops at it. Return non-nil if comma was found."
1467
1485
; ; Loop until we find a match because we must skip types we don't
1468
1486
; ; handle, such as "interface { foo() }".
1469
1487
(while (and (not found-match) (not done))
1470
- (when (looking-at (concat " [[:space:]\n ] *" go-type-name-regexp " [[:space:]]*[,:]" ))
1488
+ (when (looking-at (concat " \\ (?: [[:space:]]* \\ |//.* \\ | \n \\ ) *" go-type-name-regexp " [[:space:]]*[,:]" ))
1471
1489
(goto-char (match-end 1 ))
1472
1490
(unless (member (match-string 1 ) go-constants)
1473
1491
(setq found-match t )))
0 commit comments