File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -506,7 +506,7 @@ statements."
506
506
(" \\ (!\\ )[^=]" 1 font-lock-negation-char-face )
507
507
508
508
; ; Composite literal type
509
- (,( concat go-type-name-regexp " { " ) 1 font-lock-type-face )
509
+ (go--match-composite-literal 1 font-lock-type-face )
510
510
511
511
; ; Map value type
512
512
(go--match-map-value 1 font-lock-type-face )
@@ -1758,6 +1758,27 @@ We are looking for the right-hand-side of the type alias"
1758
1758
(eq (char-after ) ?\( ))))))
1759
1759
found-match))
1760
1760
1761
+ (defconst go--match-composite-literal-re (concat go-type-name-regexp " [[{]" ))
1762
+
1763
+ (defun go--match-composite-literal (end )
1764
+ " Search for composite literals."
1765
+ (let (found-match)
1766
+ (while (and
1767
+ (not found-match)
1768
+ ; ; Match "foo{" or "foo[".
1769
+ (re-search-forward go--match-composite-literal-re end t ))
1770
+
1771
+ (setq found-match
1772
+ (if (eq (char-before ) ?\[ )
1773
+ ; ; In "foo[" case, skip to closing "]".
1774
+ (progn
1775
+ (while (go--search-next-comma end ?\] ))
1776
+ ; ; See if closing "]" is followed by "{".
1777
+ (eq (char-after (1+ (point ))) ?{ ))
1778
+ ; ; The "foo{" case (definitely composite literal).
1779
+ (eq (char-before ) ?{ ))))
1780
+
1781
+ found-match))
1761
1782
1762
1783
(defconst go--map-value-re
1763
1784
(concat " \\ _<map\\ _>\\ [\\ (?:\\ [[^]]*\\ ]\\ )*[^]]*\\ ]" go-type-name-regexp))
Original file line number Diff line number Diff line change @@ -124,6 +124,7 @@ KcaseK string:
124
124
(go--should-fontify " TfooT{" )
125
125
(go--should-fontify " []TfooT{" )
126
126
(go--should-fontify " Tfoo.ZarT{" )
127
+ (go--should-fontify " Tfoo.ZarT[TintT]{" )
127
128
(go--should-fontify " []Tfoo.ZarT{" )
128
129
129
130
(go--should-fontify " TfooT{CbarC:baz, CquxC: 123}" )
You can’t perform that action at this time.
0 commit comments