File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -253,7 +253,11 @@ def magic_run_completer(self, event):
253253 """Complete files that end in .py or .ipy or .ipynb for the %run command.
254254 """
255255 comps = arg_split (event .line , strict = False )
256- relpath = (len (comps ) > 1 and comps [- 1 ] or '' ).strip ("'\" " )
256+ # relpath should be the current token that we need to complete.
257+ if (len (comps ) > 1 ) and (not event .line .endswith (' ' )):
258+ relpath = comps [- 1 ].strip ("'\" " )
259+ else :
260+ relpath = ''
257261
258262 #print("\nev=", event) # dbg
259263 #print("rp=", relpath) # dbg
@@ -270,7 +274,7 @@ def magic_run_completer(self, event):
270274 # be arguments to the input script.
271275
272276 if any (magic_run_re .match (c ) for c in comps ):
273- pys = [f .replace ('\\ ' ,'/' ) for f in lglob ('*' )]
277+ pys = [f .replace ('\\ ' ,'/' ) for f in lglob (relpath + '*' )]
274278 else :
275279 pys = [f .replace ('\\ ' ,'/' )
276280 for f in lglob (relpath + '*.py' ) + lglob (relpath + '*.ipy' ) +
You can’t perform that action at this time.
0 commit comments