Skip to content

Commit b40c062

Browse files
committed
Fix contract folding by adding skipnl/skipempty
Contract name matching needs to skip newlines and empty lines to properly match the opening brace for folding. Without this, contracts written with the brace on the same line as the name wouldn't fold properly.
1 parent 087eedc commit b40c062

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

syntax/solidity.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,12 @@ hi def link yulVarDeclaration Keyword
132132
hi def link yulAssemblyOp Keyword
133133

134134
" Contract
135-
syn match solContract /\<\%(contract\|library\|interface\)\>/ nextgroup=solContractName skipwhite
136-
syn match solContractName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*/ nextgroup=solContractParent,solContractBody skipwhite
135+
syn match solContract /\<\%(contract\|library\|interface\)\>/ nextgroup=solContractName skipwhite skipnl skipempty
136+
syn match solContractName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*/ nextgroup=solContractParent,solContractBody skipwhite skipnl skipempty
137137
syn region solContractParent contained start='is' end='{' contains=solContractName,solContractNoise,solContractCommas nextgroup=solContractBody skipwhite skipempty
138138
syn match solContractNoise contained 'is' containedin=solContractParent
139139
syn match solContractCommas contained ','
140-
syn region solContractBody contained start='{' end='}' fold transparent
140+
syn region solContractBody start='{' end='}' fold transparent
141141

142142
hi def link solContract Type
143143
hi def link solContractName Function

0 commit comments

Comments
 (0)