Fix crash in FastFilesCompleter with no prefix
This commit is contained in:
parent
549f5c1a47
commit
6cf515b164
|
@ -78,7 +78,8 @@ class FastFilesCompleter:
|
||||||
completion = []
|
completion = []
|
||||||
globbed = []
|
globbed = []
|
||||||
if '*' not in prefix and '?' not in prefix:
|
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 + '.*'))
|
globbed.extend(glob(prefix + '.*'))
|
||||||
prefix += '*'
|
prefix += '*'
|
||||||
globbed.extend(glob(prefix))
|
globbed.extend(glob(prefix))
|
||||||
|
@ -98,7 +99,7 @@ if os.environ.get('_ARGCOMPLETE'):
|
||||||
filescompleter = FastFilesCompleter()
|
filescompleter = FastFilesCompleter()
|
||||||
|
|
||||||
def try_argcomplete(parser):
|
def try_argcomplete(parser):
|
||||||
argcomplete.autocomplete(parser)
|
argcomplete.autocomplete(parser, always_complete_options=False)
|
||||||
else:
|
else:
|
||||||
def try_argcomplete(parser):
|
def try_argcomplete(parser):
|
||||||
pass
|
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
|
from _pytest._argcomplete import FastFilesCompleter
|
||||||
ffc = FastFilesCompleter()
|
ffc = FastFilesCompleter()
|
||||||
fc = FilesCompleter()
|
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)
|
assert equal_with_bash(x, ffc, fc, out=py.std.sys.stdout)
|
||||||
|
|
||||||
@pytest.mark.skipif("sys.platform in ('win32', 'darwin')")
|
@pytest.mark.skipif("sys.platform in ('win32', 'darwin')")
|
||||||
|
|
Loading…
Reference in New Issue