Skip to content

Commit 7e418c5

Browse files
committed
Improve completion edge cases
- Allow negative numbers in square brackets - Don't try to complete number literals or incomplete strings
1 parent c592d70 commit 7e418c5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ftplugin/python/ipy.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ fun! CompleteIPython(findstart, base)
306306
while s:start > 0 && (line[s:start-1] =~ s:split_pattern
307307
\ || (g:ipython_greedy_matching && line[s:start-1] == '.'
308308
\ && s:start >= 2 && line[s:start-2] =~ '\k')
309+
\ || (g:ipython_greedy_matching && line[s:start-1] == '-'
310+
\ && s:start >= 2 && line[s:start-2] == '[')
309311
\ || join(line[s:start-2:s:start-1], '') ==# '].')
310312
if g:ipython_greedy_matching && line[s:start-1] == '['
311313
if (s:start == 1 || line[s:start-2] !~ '\k\|\]')
@@ -325,6 +327,10 @@ fun! CompleteIPython(findstart, base)
325327
" find months matching with "a:base"
326328
let res = []
327329
if s:start == -1 | return [] | endif
330+
" don't complete numeric literals
331+
if a:base =~? '\v^[-+]?\d*\.?\d+(e[-+]?\d+)?\.$' | return [] | endif
332+
" don't complete incomplete string literals
333+
if a:base =~? '\v^(([^''].*)?['']|([^"].*)?["])\.$' | return [] | endif
328334
let start = s:start
329335
Python2or3 << endpython
330336
base = vim.eval("a:base")

0 commit comments

Comments
 (0)