Skip to content

Commit e487b6e

Browse files
committed
Fix issue where identifiers after case statements in switch statements nested inside type switch statements were highlighted as types
1 parent 8ea7f30 commit e487b6e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
- Fix issue with slice of pointer type not highlighting user-defined types
2323
correctly
24+
- Fix issue where identifiers after case statements in switch statements nested
25+
inside type switch statements were highlighted as types
2426

2527
## Version 0.1.0 - 2022/12/26
2628

syntax/go.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,10 @@ syntax keyword goSelect select contained
642642
syntax keyword goSwitchKeywords case fallthrough default contained
643643

644644
syntax match goSwitchTypeCase /^\s\+case\s/ contained skipwhite nextgroup=@goType
645-
syntax region goSwitchTypeBlock matchgroup=goSwitchTypeBraces start='{' end='}' contained contains=goSwitchTypeCase,@goStatement
645+
syntax region goSwitchTypeBlock matchgroup=goSwitchTypeBraces start='{' end='}' contained contains=goSwitchTypeCase,goSwitchTypeBlockNestedBraces,@goStatement
646+
647+
" goSwitchTypeBlockNestedBraces prevents goSwitchTypeCase from matching "case" in a regular nested switch statement
648+
syntax region goSwitchTypeBlockNestedBraces matchgroup=goBraces start='{' end='}' contained contains=@goStatement
646649

647650
hi link goIf Conditional
648651
hi link goElse goIf
@@ -666,9 +669,10 @@ syntax keyword goKeywords defer go contained
666669

667670
" goTypeAssertion is a part of the nextgroup list of goDotExpr
668671
syntax region goTypeAssertion matchgroup=goParens start=/(/ end=/)/ contained contains=@goType
669-
syntax match goTypeAssertion /(type)/ contained contains=goParenBlock,goTypeDecl skipwhite nextgroup=goSwitchTypeBlock
672+
syntax match goTypeAssertion /(type)/ contained contains=goParenBlock skipwhite nextgroup=goSwitchTypeBlock
670673

671-
hi link goKeywords Keyword
674+
hi link goKeywords Keyword
675+
hi link goTypeAssertion Special
672676

673677
" }}} Misc
674678

0 commit comments

Comments
 (0)