90
90
endif
91
91
92
92
" Find backwards the closest open parenthesis/bracket/brace.
93
- function ! s: find_opening_paren (... )
94
- " optional arguments: line and column (defaults to 1) to search around
95
- if a: 0 > 0
96
- let view = winsaveview ()
97
- call cursor (a: 1 , a: 0 > 1 ? a: 2 : 1 )
98
- let ret = s: find_opening_paren ()
99
- call winrestview (view )
100
- return ret
101
- endif
102
-
93
+ function ! s: find_opening_paren (lnum, col )
103
94
" Return if cursor is in a comment.
104
- if synIDattr (synID (line ( ' . ' ), col ( ' . ' ) , 0 ), ' name' ) = ~? ' comment'
95
+ if synIDattr (synID (a: lnum , a: col , 0 ), ' name' ) = ~? ' comment'
105
96
return [0 , 0 ]
106
97
endif
107
98
99
+ call cursor (a: lnum , a: col )
100
+
108
101
let nearest = [0 , 0 ]
109
102
for [p , maxoff] in items (s: paren_pairs )
110
103
let stopline = max ([0 , line (' .' ) - maxoff, nearest[0 ]])
@@ -124,7 +117,7 @@ function! s:find_start_of_multiline_statement(lnum)
124
117
if getline (lnum - 1 ) = ~# ' \\$'
125
118
let lnum = prevnonblank (lnum - 1 )
126
119
else
127
- let [paren_lnum, _] = s: find_opening_paren (lnum)
120
+ let [paren_lnum, _] = s: find_opening_paren (lnum, 1 )
128
121
if paren_lnum < 1
129
122
return lnum
130
123
else
@@ -181,7 +174,7 @@ endfunction
181
174
182
175
" Line up with open parenthesis/bracket/brace.
183
176
function ! s: indent_like_opening_paren (lnum)
184
- let [paren_lnum, paren_col] = s: find_opening_paren (a: lnum )
177
+ let [paren_lnum, paren_col] = s: find_opening_paren (a: lnum, 1 )
185
178
if paren_lnum <= 0
186
179
return -2
187
180
endif
@@ -211,7 +204,7 @@ function! s:indent_like_opening_paren(lnum)
211
204
" from the next logical line.
212
205
if text = ~# b: control_statement && res == base + s: sw ()
213
206
" But only if not inside parens itself (Flake's E127).
214
- let [paren_lnum, _] = s: find_opening_paren (paren_lnum)
207
+ let [paren_lnum, _] = s: find_opening_paren (paren_lnum, 1 )
215
208
if paren_lnum <= 0
216
209
return res + s: sw ()
217
210
endif
0 commit comments