[IPython-dev] tab completion w/ spaces in filename - still broken

Fernando Perez Fernando.Perez at colorado.edu
Thu Jul 1 02:47:50 EDT 2004

Ok, here's the best I could do with this as a patch against CVS.  I played for 
a while with readline, and it _almost_ works, but it's ugly.  Here's the behavior:

maqroll[~/test]|1> ls div*
div.c  div.f  div.py
maqroll[~/test]|2> cat div <TAB HERE>
div.c   div.f   div.py
maqroll[~/test]|2> cat div. <TAB HERE>
div.c   div.f   div.py
maqroll[~/test]|2> ls aa*
aa b c  aa b d
maqroll[~/test]|3> cat aa <TAB HERE>
aa\ b\ c  aa\ b\ d
maqroll[~/test]|3> cat aa\ b\ <TAB HERE>
c  d

As you can see, when the filenames have spaces in them, the printed 
completions are only the ends instead of the full names.  This is a bit 
disconcerting, but I failed to fix it and I can't really spend much more time 
on this.

At least it _does_ provide the correct completions, so while I'm not quite 
100% happy, for now I may leave it at that unless you can finish fixing it.

It does need a bit of cleaning (easy), and I'd move the regex to an init-time 
instance var to avoid the extra dict lookups of the compile on every complete 
call.  But that's a minor optimization for later.  It would be great if you 
can hammer the last bit on this one (or provide an alternative which works 
100% correctly).

Note that I also didn't test every combination of funny filenames/spaces 
possible, so I may have missed a corner case.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: space_completers.diff
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20040701/9ad16914/attachment.ksh>

More information about the IPython-dev mailing list