@@ -77,9 +77,6 @@ if has('conceal')
7777endif
7878
7979
80- let s: skip_search = ' synIDattr(synID(line("."), col("."), 0), "name") ' .
81- \ ' =~? "comment"'
82-
8380" Use 'shiftwidth()' instead of '&sw'.
8481" (Since Vim patch 7.3.629, 'shiftwidth' can be set to 0 to follow 'tabstop').
8582if exists (' *shiftwidth' )
9390endif
9491
9592" Find backwards the closest open parenthesis/bracket/brace.
96- function ! s: find_opening_paren (... )
97- " optional arguments: line and column (defaults to 1) to search around
98- if a: 0 > 0
99- let view = winsaveview ()
100- call cursor (a: 1 , a: 0 > 1 ? a: 2 : 1 )
101- let ret = s: find_opening_paren ()
102- call winrestview (view )
103- return ret
93+ function ! s: find_opening_paren (lnum, col )
94+ " Return if cursor is in a comment.
95+ if synIDattr (synID (a: lnum , a: col , 0 ), ' name' ) = ~? ' comment'
96+ return [0 , 0 ]
10497 endif
10598
106- " Return if cursor is in a comment.
107- exe ' if' s: skip_search ' | return [0, 0] | endif'
99+ call cursor (a: lnum , a: col )
108100
109101 let nearest = [0 , 0 ]
110102 for [p , maxoff] in items (s: paren_pairs )
@@ -125,7 +117,7 @@ function! s:find_start_of_multiline_statement(lnum)
125117 if getline (lnum - 1 ) = ~# ' \\$'
126118 let lnum = prevnonblank (lnum - 1 )
127119 else
128- let [paren_lnum, _] = s: find_opening_paren (lnum)
120+ let [paren_lnum, _] = s: find_opening_paren (lnum, 1 )
129121 if paren_lnum < 1
130122 return lnum
131123 else
@@ -182,7 +174,7 @@ endfunction
182174
183175" Line up with open parenthesis/bracket/brace.
184176function ! s: indent_like_opening_paren (lnum)
185- let [paren_lnum, paren_col] = s: find_opening_paren (a: lnum )
177+ let [paren_lnum, paren_col] = s: find_opening_paren (a: lnum, 1 )
186178 if paren_lnum <= 0
187179 return -2
188180 endif
@@ -212,7 +204,7 @@ function! s:indent_like_opening_paren(lnum)
212204 " from the next logical line.
213205 if text = ~# b: control_statement && res == base + s: sw ()
214206 " But only if not inside parens itself (Flake's E127).
215- let [paren_lnum, _] = s: find_opening_paren (paren_lnum)
207+ let [paren_lnum, _] = s: find_opening_paren (paren_lnum, 1 )
216208 if paren_lnum <= 0
217209 return res + s: sw ()
218210 endif
0 commit comments