Skip to content

Commit 289b134

Browse files
committed
Intermediate fix for indenting huge dicts
This uses different offsets for the type of pairs: '()' and '[]' will only look for just 20 lines above, while 1000 lines are used for '{}', which might be a huge dict. Ref: #64.
1 parent e0be8bf commit 289b134

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

indent/python.vim

+3-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ if !exists('g:python_pep8_indent_multiline_string')
3434
let g:python_pep8_indent_multiline_string = 0
3535
endif
3636

37-
let s:maxoff = 50
3837
let s:block_rules = {
3938
\ '^\s*elif\>': ['if', 'elif'],
4039
\ '^\s*except\>': ['try', 'except'],
@@ -43,7 +42,7 @@ let s:block_rules = {
4342
let s:block_rules_multiple = {
4443
\ '^\s*else\>': ['if', 'elif', 'for', 'try', 'except'],
4544
\ }
46-
let s:paren_pairs = ['()', '{}', '[]']
45+
let s:paren_pairs = {'()': 20, '[]': 20, '{}': 1000}
4746
if &filetype ==# 'pyrex' || &filetype ==# 'cython'
4847
let b:control_statement = '\v^\s*(class|def|if|while|with|for|except|cdef|cpdef)>'
4948
else
@@ -105,13 +104,12 @@ function! s:find_opening_paren(...)
105104
return ret
106105
endif
107106

108-
let stopline = max([0, line('.') - s:maxoff])
109-
110107
" Return if cursor is in a comment.
111108
exe 'if' s:skip_search '| return [0, 0] | endif'
112109

113110
let positions = []
114-
for p in s:paren_pairs
111+
for [p, maxoff] in items(s:paren_pairs)
112+
let stopline = max([0, line('.') - maxoff])
115113
call add(positions, searchpairpos(
116114
\ '\V'.p[0], '', '\V'.p[1], 'bnW', s:skip_special_chars, stopline))
117115
endfor

0 commit comments

Comments
 (0)