Skip to content

Commit c592d70

Browse files
committed
Better handling of brackets in complete findstart
Example test cases: data1[test[0]][' items[items['enum']<50]. items[items[' data3['aspernatur']['
1 parent 206a238 commit c592d70

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ftplugin/python/ipy.vim

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,19 @@ fun! CompleteIPython(findstart, base)
302302
return s:start
303303
endif
304304
let s:start = strchars(getline('.')[:col('.')-1]) - 1
305+
let bracket_level = 0
305306
while s:start > 0 && (line[s:start-1] =~ s:split_pattern
306307
\ || (g:ipython_greedy_matching && line[s:start-1] == '.'
307308
\ && s:start >= 2 && line[s:start-2] =~ '\k')
308309
\ || join(line[s:start-2:s:start-1], '') ==# '].')
309-
if g:ipython_greedy_matching && line[s:start-1] == '[' &&
310-
\ (s:start == 1 || line[s:start-2] !~ '\k\|\]')
311-
break
310+
if g:ipython_greedy_matching && line[s:start-1] == '['
311+
if (s:start == 1 || line[s:start-2] !~ '\k\|\]')
312+
\ || bracket_level > 0
313+
break
314+
endif
315+
let bracket_level += 1
316+
elseif g:ipython_greedy_matching && line[s:start-1] == ']'
317+
let bracket_level -= 1
312318
endif
313319
let s:start -= 1
314320
endwhile

0 commit comments

Comments
 (0)