9090endif
9191
9292" 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 )
10394 " 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'
10596 return [0 , 0 ]
10697 endif
10798
99+ call cursor (a: lnum , a: col )
100+
108101 let nearest = [0 , 0 ]
109102 for [p , maxoff] in items (s: paren_pairs )
110103 let stopline = max ([0 , line (' .' ) - maxoff, nearest[0 ]])
@@ -124,7 +117,7 @@ function! s:find_start_of_multiline_statement(lnum)
124117 if getline (lnum - 1 ) = ~# ' \\$'
125118 let lnum = prevnonblank (lnum - 1 )
126119 else
127- let [paren_lnum, _] = s: find_opening_paren (lnum)
120+ let [paren_lnum, _] = s: find_opening_paren (lnum, 1 )
128121 if paren_lnum < 1
129122 return lnum
130123 else
@@ -181,7 +174,7 @@ endfunction
181174
182175" Line up with open parenthesis/bracket/brace.
183176function ! 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 )
185178 if paren_lnum <= 0
186179 return -2
187180 endif
@@ -211,7 +204,7 @@ function! s:indent_like_opening_paren(lnum)
211204 " from the next logical line.
212205 if text = ~# b: control_statement && res == base + s: sw ()
213206 " 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 )
215208 if paren_lnum <= 0
216209 return res + s: sw ()
217210 endif
0 commit comments