Skip to content

Commit 659cbf3

Browse files
committed
Fix switch cases from being detected as labels
1 parent f11f948 commit 659cbf3

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

syntax/javascript.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,22 @@ exe 'syntax keyword jsThis this '.(exists('g:javascript_conceal
9696
exe 'syntax keyword jsSuper super contained '.(exists('g:javascript_conceal_super') ? 'conceal cchar='.g:javascript_conceal_super : '')
9797

9898
" Statement Keywords
99+
syntax match jsBlockLabel /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\s*:/ contains=jsNoise skipwhite skipempty nextgroup=jsBlock
100+
syntax match jsBlockLabelKey contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\%(\s*\%(;\|\n\)\)\@=/
99101
syntax keyword jsStatement contained with yield debugger
100102
syntax keyword jsStatement contained break continue skipwhite skipempty nextgroup=jsBlockLabelKey
101103
syntax keyword jsConditional if skipwhite skipempty nextgroup=jsParenIfElse
102104
syntax keyword jsConditional else skipwhite skipempty nextgroup=jsCommentMisc,jsIfElseBlock
103105
syntax keyword jsConditional switch skipwhite skipempty nextgroup=jsParenSwitch
104106
syntax keyword jsRepeat while for skipwhite skipempty nextgroup=jsParenRepeat,jsForAwait
105107
syntax keyword jsDo do skipwhite skipempty nextgroup=jsRepeatBlock
106-
syntax keyword jsLabel contained case default
108+
syntax region jsSwitchCase contained matchgroup=jsLabel start=/\<\%(case\|default\)\>/ end=/:\@=/ contains=@jsExpression,jsLabel skipwhite skipempty nextgroup=jsSwitchColon keepend
107109
syntax keyword jsTry try skipwhite skipempty nextgroup=jsTryCatchBlock
108110
syntax keyword jsFinally contained finally skipwhite skipempty nextgroup=jsFinallyBlock
109111
syntax keyword jsCatch contained catch skipwhite skipempty nextgroup=jsParenCatch
110112
syntax keyword jsException throw
111113
syntax keyword jsAsyncKeyword async await
112114
syntax match jsSwitchColon contained /:/ skipwhite skipempty nextgroup=jsSwitchBlock
113-
syntax match jsBlockLabel /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\s*:/ contains=jsNoise skipwhite skipempty nextgroup=jsBlock
114-
syntax match jsBlockLabelKey contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*\>\%(\s*\%(;\|\n\)\)\@=/
115115

116116
" Keywords
117117
syntax keyword jsGlobalObjects Array Boolean Date Function Iterator Number Object Symbol Map WeakMap Set RegExp String Proxy Promise Buffer ParallelArray ArrayBuffer DataView Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray JSON Math console document window Intl Collator DateTimeFormat NumberFormat fetch
@@ -150,7 +150,7 @@ syntax region jsFuncBlock contained matchgroup=jsFuncBraces s
150150
syntax region jsIfElseBlock contained matchgroup=jsIfElseBraces start=/{/ end=/}/ contains=@jsAll,jsBlock extend fold
151151
syntax region jsTryCatchBlock contained matchgroup=jsTryCatchBraces start=/{/ end=/}/ contains=@jsAll,jsBlock skipwhite skipempty nextgroup=jsCatch,jsFinally extend fold
152152
syntax region jsFinallyBlock contained matchgroup=jsFinallyBraces start=/{/ end=/}/ contains=@jsAll,jsBlock extend fold
153-
syntax region jsSwitchBlock contained matchgroup=jsSwitchBraces start=/{/ end=/}/ contains=@jsAll,jsBlock,jsLabel,jsSwitchColon extend fold
153+
syntax region jsSwitchBlock contained matchgroup=jsSwitchBraces start=/{/ end=/}/ contains=@jsAll,jsBlock,jsSwitchCase extend fold
154154
syntax region jsRepeatBlock contained matchgroup=jsRepeatBraces start=/{/ end=/}/ contains=@jsAll,jsBlock extend fold
155155
syntax region jsDestructuringBlock contained matchgroup=jsDestructuringBraces start=/{/ end=/}/ contains=jsDestructuringProperty,jsDestructuringAssignment,jsDestructuringNoise,jsDestructuringPropertyComputed,jsSpreadExpression,jsComment extend fold
156156
syntax region jsDestructuringArray contained matchgroup=jsDestructuringBraces start=/\[/ end=/\]/ contains=jsDestructuringPropertyValue,jsNoise,jsDestructuringProperty,jsSpreadExpression,jsComment extend fold

0 commit comments

Comments
 (0)