aboutsummaryrefslogtreecommitdiff
path: root/runtime/indent/python.vim
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-10-30 01:01:29 +0100
committerGitHub <noreply@github.com>2018-10-30 01:01:29 +0100
commit500345aea2ef88b45e0905043ed435ad4676bcef (patch)
treec7def1cc1de8c7c869560eb9770ee6067ae1323d /runtime/indent/python.vim
parentf5406dfe7772dca82e31f27c042c5718198f0ec8 (diff)
parent18ce6c90636abae594905eecf2e225124ae8ab17 (diff)
downloadrneovim-500345aea2ef88b45e0905043ed435ad4676bcef.tar.gz
rneovim-500345aea2ef88b45e0905043ed435ad4676bcef.tar.bz2
rneovim-500345aea2ef88b45e0905043ed435ad4676bcef.zip
Merge #9172 from justinmk/vim-d473c8c10126
Diffstat (limited to 'runtime/indent/python.vim')
-rw-r--r--runtime/indent/python.vim14
1 files changed, 11 insertions, 3 deletions
diff --git a/runtime/indent/python.vim b/runtime/indent/python.vim
index 4ce3c234a5..7ab3cb9f50 100644
--- a/runtime/indent/python.vim
+++ b/runtime/indent/python.vim
@@ -53,6 +53,11 @@ function GetPythonIndent(lnum)
return 0
endif
+ " searchpair() can be slow sometimes, limit the time to 100 msec or what is
+ " put in g:pyindent_searchpair_timeout
+ let searchpair_stopline = 0
+ let searchpair_timeout = get(g:, 'pyindent_searchpair_timeout', 150)
+
" If the previous line is inside parenthesis, use the indent of the starting
" line.
" Trick: use the non-existing "dummy" variable to break out of the loop when
@@ -61,7 +66,8 @@ function GetPythonIndent(lnum)
let parlnum = searchpair('(\|{\|\[', '', ')\|}\|\]', 'nbW',
\ "line('.') < " . (plnum - s:maxoff) . " ? dummy :"
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
- \ . " =~ '\\(Comment\\|Todo\\|String\\)$'")
+ \ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
+ \ searchpair_stopline, searchpair_timeout)
if parlnum > 0
let plindent = indent(parlnum)
let plnumstart = parlnum
@@ -80,14 +86,16 @@ function GetPythonIndent(lnum)
let p = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW',
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
- \ . " =~ '\\(Comment\\|Todo\\|String\\)$'")
+ \ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
+ \ searchpair_stopline, searchpair_timeout)
if p > 0
if p == plnum
" When the start is inside parenthesis, only indent one 'shiftwidth'.
let pp = searchpair('(\|{\|\[', '', ')\|}\|\]', 'bW',
\ "line('.') < " . (a:lnum - s:maxoff) . " ? dummy :"
\ . " synIDattr(synID(line('.'), col('.'), 1), 'name')"
- \ . " =~ '\\(Comment\\|Todo\\|String\\)$'")
+ \ . " =~ '\\(Comment\\|Todo\\|String\\)$'",
+ \ searchpair_stopline, searchpair_timeout)
if pp > 0
return indent(plnum) + (exists("g:pyindent_nested_paren") ? eval(g:pyindent_nested_paren) : shiftwidth())
endif