Fix crash in FastFilesCompleter with no prefix
This commit is contained in:
parent
549f5c1a47
commit
6cf515b164
|
@ -78,7 +78,8 @@ class FastFilesCompleter:
|
|||
completion = []
|
||||
globbed = []
|
||||
if '*' not in prefix and '?' not in prefix:
|
||||
if prefix[-1] == os.path.sep: # we are on unix, otherwise no bash
|
||||
# we are on unix, otherwise no bash
|
||||
if not prefix or prefix[-1] == os.path.sep:
|
||||
globbed.extend(glob(prefix + '.*'))
|
||||
prefix += '*'
|
||||
globbed.extend(glob(prefix))
|
||||
|
@ -98,7 +99,7 @@ if os.environ.get('_ARGCOMPLETE'):
|
|||
filescompleter = FastFilesCompleter()
|
||||
|
||||
def try_argcomplete(parser):
|
||||
argcomplete.autocomplete(parser)
|
||||
argcomplete.autocomplete(parser, always_complete_options=False)
|
||||
else:
|
||||
def try_argcomplete(parser):
|
||||
pass
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Fix crash in tab completion when no prefix is given.
|
|
@ -82,7 +82,7 @@ class TestArgComplete(object):
|
|||
from _pytest._argcomplete import FastFilesCompleter
|
||||
ffc = FastFilesCompleter()
|
||||
fc = FilesCompleter()
|
||||
for x in '/ /d /data qqq'.split():
|
||||
for x in ['/', '/d', '/data', 'qqq', '']:
|
||||
assert equal_with_bash(x, ffc, fc, out=py.std.sys.stdout)
|
||||
|
||||
@pytest.mark.skipif("sys.platform in ('win32', 'darwin')")
|
||||
|
|
Loading…
Reference in New Issue