@@ -38,6 +38,15 @@ if !exists('g:python_pep8_indent_hang_closing')
38
38
let g: python_pep8_indent_hang_closing = 0
39
39
endif
40
40
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
+
41
50
let s: block_rules = {
42
51
\ ' ^\s*elif\>' : [' if' , ' elif' ],
43
52
\ ' ^\s*except\>' : [' try' , ' except' ],
@@ -110,7 +119,7 @@ function! s:find_opening_paren(...)
110
119
for [p , maxoff] in items (s: paren_pairs )
111
120
let stopline = max ([0 , line (' .' ) - maxoff, nearest[0 ]])
112
121
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 )
114
123
if next [0 ] && (next [0 ] > nearest[0 ] || (next [0 ] == nearest[0 ] && next [1 ] > nearest[1 ]))
115
124
let nearest = next
116
125
endif
@@ -364,7 +373,7 @@ function! GetPythonPEPIndent(lnum)
364
373
if match_quotes != -1
365
374
" closing multiline string
366
375
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 )
368
377
if pairpos[0 ] != 0
369
378
return indent (pairpos[0 ])
370
379
else
0 commit comments