Skip to content

Commit e37208b

Browse files
committed
Fix folding and indent test suites
1 parent f0ffbaa commit e37208b

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

syntax/solidity.vim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ syn match solModifierName contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*/ nextgrou
115115
syn region solModifierArgs contained matchgroup=solFuncParens start='(' end=')' contains=solFuncArgCommas nextgroup=solModifierName,solFuncReturns,solFuncBody skipwhite
116116
syn region solFuncReturns contained matchgroup=solFuncParens nextgroup=solFuncBody start='(' end=')' contains=solFuncArgCommas,solBuiltinType skipwhite
117117
syn match solFuncArgCommas contained ','
118-
syn region solFuncBody start="{" end="}" fold transparent
118+
syn region solFuncBody contained start="{" end="}" fold transparent
119119

120120
hi def link solFunction Type
121121
hi def link solFuncName Function
@@ -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
137-
syn region solContractParent contained start='is' end='{' contains=solContractName,solContractNoise,solContractCommas nextgroup=solContractBody skipwhite skipempty
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=solContractBlock,solContractParent skipwhite skipnl skipempty
137+
syn region solContractParent contained start='is' end='{' contains=solContractName,solContractNoise,solContractCommas nextgroup=solContractBlock 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 solContractBlock contained matchgroup=Delimiter start='{' end='}' fold transparent
141141

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

test/vader/folding.vader

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
" Code folding tests for vim-solidity
22

33
Before:
4-
set rtp+=.
4+
set rtp^=.
55
filetype plugin indent on
66
syntax enable
77
set foldmethod=syntax
88
set foldlevel=0
99

10-
After:
11-
%bwipeout!
12-
set foldmethod=manual
13-
1410
# ==============================================================================
1511
# Function Folding
1612
# ==============================================================================
@@ -25,8 +21,8 @@ Given solidity (function with body):
2521
Execute (function body should be foldable):
2622
normal! gg
2723
" Check that fold exists
28-
let l:foldlevel = foldlevel(1)
29-
AssertNotEqual 0, l:foldlevel
24+
let g:fold_level = foldlevel(1)
25+
AssertNotEqual 0, g:fold_level
3026

3127
# ==============================================================================
3228
# Contract Folding (Issue #11)
@@ -45,11 +41,11 @@ Execute (contract body should be foldable):
4541
normal! gg
4642
" Find the opening brace line
4743
normal! /{
48-
let l:contract_line = line('.')
44+
let g:contract_line = line('.')
4945
" Contract body should have a fold
50-
let l:foldlevel = foldlevel(l:contract_line + 1)
46+
let g:fold_level = foldlevel(g:contract_line + 1)
5147
" If contract folding is working, there should be a fold level
52-
AssertNotEqual 0, l:foldlevel
48+
AssertNotEqual 0, g:fold_level
5349

5450
# ==============================================================================
5551
# Assembly Folding
@@ -66,9 +62,9 @@ Given solidity (assembly block):
6662
Execute (assembly block should be foldable):
6763
normal! /assembly
6864
normal! /{
69-
let l:asm_line = line('.')
70-
let l:foldlevel = foldlevel(l:asm_line + 1)
71-
AssertNotEqual 0, l:foldlevel
65+
let g:asm_line = line('.')
66+
let g:fold_level = foldlevel(g:asm_line + 1)
67+
AssertNotEqual 0, g:fold_level
7268

7369
# ==============================================================================
7470
# Multi-line Comment Folding
@@ -82,6 +78,6 @@ Given solidity (multi-line comment):
8278

8379
Execute (multi-line comment should be foldable):
8480
normal! gg
85-
let l:foldlevel = foldlevel(1)
81+
let g:fold_level = foldlevel(1)
8682
" Comments should have fold support
87-
AssertNotEqual 0, l:foldlevel
83+
AssertNotEqual 0, g:fold_level

test/vader/indent.vader

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
" Indentation tests for vim-solidity
22

33
Before:
4-
set rtp+=.
4+
set rtp^=.
55
filetype plugin indent on
66
syntax enable
77

8-
After:
9-
%bwipeout!
10-
118
# ==============================================================================
129
# Basic Indentation
1310
# ==============================================================================

0 commit comments

Comments
 (0)