diff --git a/IPython/core/completerlib.py b/IPython/core/completerlib.py index bddd412..243c7d9 100644 --- a/IPython/core/completerlib.py +++ b/IPython/core/completerlib.py @@ -267,20 +267,23 @@ def magic_run_completer(self, event): isdir = os.path.isdir relpath, tilde_expand, tilde_val = expand_user(relpath) - dirs = [f.replace('\\','/') + "/" for f in lglob(relpath+'*') if isdir(f)] - # Find if the user has already typed the first filename, after which we # should complete on all files, since after the first one other files may # be arguments to the input script. if any(magic_run_re.match(c) for c in comps): - pys = [f.replace('\\','/') for f in lglob(relpath+'*')] + matches = [f.replace('\\','/') + ('/' if isdir(f) else '') + for f in lglob(relpath+'*')] else: + dirs = [f.replace('\\','/') + "/" for f in lglob(relpath+'*') if isdir(f)] pys = [f.replace('\\','/') for f in lglob(relpath+'*.py') + lglob(relpath+'*.ipy') + lglob(relpath+'*.ipynb') + lglob(relpath + '*.pyw')] + + matches = dirs + pys + #print('run comp:', dirs+pys) # dbg - return [compress_user(p, tilde_expand, tilde_val) for p in dirs+pys] + return [compress_user(p, tilde_expand, tilde_val) for p in matches] def cd_completer(self, event): diff --git a/IPython/core/tests/test_completerlib.py b/IPython/core/tests/test_completerlib.py index 4efd272..7c55393 100644 --- a/IPython/core/tests/test_completerlib.py +++ b/IPython/core/tests/test_completerlib.py @@ -32,7 +32,7 @@ class MockEvent(object): #----------------------------------------------------------------------------- class Test_magic_run_completer(unittest.TestCase): files = [u"aao.py", u"a.py", u"b.py", u"aao.txt"] - dirs = [u"adir", "bdir"] + dirs = [u"adir/", "bdir/"] def setUp(self): self.BASETESTDIR = tempfile.mkdtemp() @@ -83,7 +83,7 @@ class Test_magic_run_completer(unittest.TestCase): print(repr(event.line)) match = set(magic_run_completer(None, event)) self.assertEqual(match, {join(self.BASETESTDIR, f) for - f in (u'a.py', u'aao.py', u'aao.txt', u'adir')}) + f in (u'a.py', u'aao.py', u'aao.txt', u'adir/')}) class Test_magic_run_completer_nonascii(unittest.TestCase): @onlyif_unicode_paths