@@ -38,6 +38,15 @@ if !exists('g:python_pep8_indent_hang_closing')
3838 let g: python_pep8_indent_hang_closing = 0
3939endif
4040
41+ " TODO: check required patch for timeout argument, likely lower than 7.3.429 though.
42+ if ! exists (' g:python_pep8_indent_searchpair_timeout' )
43+ if has (' patch-8.0.1483' )
44+ let g: python_pep8_indent_searchpair_timeout = 150
45+ else
46+ let g: python_pep8_indent_searchpair_timeout = 0
47+ endif
48+ endif
49+
4150let s: block_rules = {
4251 \ ' ^\s*elif\>' : [' if' , ' elif' ],
4352 \ ' ^\s*except\>' : [' try' , ' except' ],
@@ -110,7 +119,7 @@ function! s:find_opening_paren(...)
110119 for [p , maxoff] in items (s: paren_pairs )
111120 let stopline = max ([0 , line (' .' ) - maxoff, nearest[0 ]])
112121 let next = searchpairpos (
113- \ ' \V' .p [0 ], ' ' , ' \V' .p [1 ], ' bnW' , s: skip_special_chars , stopline)
122+ \ ' \V' .p [0 ], ' ' , ' \V' .p [1 ], ' bnW' , s: skip_special_chars , stopline, g: python_pep8_indent_searchpair_timeout )
114123 if next [0 ] && (next [0 ] > nearest[0 ] || (next [0 ] == nearest[0 ] && next [1 ] > nearest[1 ]))
115124 let nearest = next
116125 endif
@@ -364,7 +373,7 @@ function! GetPythonPEPIndent(lnum)
364373 if match_quotes != -1
365374 " closing multiline string
366375 let quotes = line [match_quotes: (match_quotes+ 2 )]
367- let pairpos = searchpairpos (quotes, ' ' , quotes, ' b' )
376+ let pairpos = searchpairpos (quotes, ' ' , quotes, ' b' , 1 , g: python_pep8_indent_searchpair_timeout )
368377 if pairpos[0 ] != 0
369378 return indent (pairpos[0 ])
370379 else
0 commit comments