Skip to content

Commit bcf4146

Browse files
committedNov 16, 2018
Add g:python_pep8_indent_searchpair_timeout
Ref: Vimjas#116
1 parent f196c5b commit bcf4146

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

‎indent/python.vim

+11-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ if !exists('g:python_pep8_indent_hang_closing')
3838
let g:python_pep8_indent_hang_closing = 0
3939
endif
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+
4150
let 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

Comments
 (0)