##// END OF EJS Templates
- Small dir. completion fix, problem reported by Stefan.
fperez -
Show More
@@ -373,6 +373,22 b' class IPCompleter(Completer):'
373 return "".join([(ch in protectables and '\\' + ch or ch)
373 return "".join([(ch in protectables and '\\' + ch or ch)
374 for ch in s])
374 for ch in s])
375
375
376 def single_dir_expand(matches):
377 "Recursively expand match lists containing a single dir."
378
379 if len(matches) == 1 and os.path.isdir(matches[0]):
380 # Takes care of links to directories also. Use '/'
381 # explicitly, even under Windows, so that name completions
382 # don't end up escaped.
383 d = matches[0]
384 if d[-1] in ['/','\\']:
385 d = d[:-1]
386
387 matches = [ (d + '/' + p) for p in os.listdir(d) ]
388 return single_dir_expand(matches)
389 else:
390 return matches
391
376 lbuf = self.lbuf
392 lbuf = self.lbuf
377 open_quotes = 0 # track strings with open quotes
393 open_quotes = 0 # track strings with open quotes
378 try:
394 try:
@@ -420,17 +436,8 b' class IPCompleter(Completer):'
420 else:
436 else:
421 matches = [text_prefix +
437 matches = [text_prefix +
422 protect_filename(f) for f in m0]
438 protect_filename(f) for f in m0]
423 if len(matches) == 1 and os.path.isdir(matches[0]):
424 # Takes care of links to directories also. Use '/'
425 # explicitly, even under Windows, so that name completions
426 # don't end up escaped.
427 d = matches[0]
428 if d[-1] in ['/','\\']:
429 d = d[:-1]
430
439
431 matches = [ (d + '/' + p) for p in os.listdir(d) ]
440 return single_dir_expand(matches)
432
433 return matches
434
441
435 def alias_matches(self, text):
442 def alias_matches(self, text):
436 """Match internal system aliases"""
443 """Match internal system aliases"""
@@ -1,5 +1,10 b''
1 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
1 2007-03-18 Fernando Perez <Fernando.Perez@colorado.edu>
2
2
3 * IPython/completer.py
4 (IPCompleter.file_matches.single_dir_expand): fix a problem
5 reported by Stefan, where directories containign a single subdir
6 would be completed too early.
7
3 * IPython/Shell.py (_load_pylab): Make the execution of 'from
8 * IPython/Shell.py (_load_pylab): Make the execution of 'from
4 pylab import *' when -pylab is given be optional. A new flag,
9 pylab import *' when -pylab is given be optional. A new flag,
5 pylab_import_all controls this behavior, the default is True for
10 pylab_import_all controls this behavior, the default is True for
General Comments 0
You need to be logged in to leave comments. Login now