Skip to content

Tab completion of `~/` shows no output post 0.10.x #869

Closed
fperez opened this Issue Oct 13, 2011 · 5 comments

4 participants

@fperez
IPython member
fperez commented Oct 13, 2011

This is a regression: in 0.10.x, doing cd ~/<TAB> properly completed, but now we only complete if there's at least a letter added after the /.

@ivanov
IPython member
@fperez
IPython member
fperez commented Oct 13, 2011

Thanks for the data point, @ivanov. That's because ls is an alias while cd is a magic, and there are separate codepaths. But it's useful, as it helps us narrow where the broken part may lie.

@takluyver
IPython member

It seems to be kind of working for me either with cd or ls. The ~/ gets expanded to /home/thomas/ within the line, but I still see the completions.

@minrk minrk added a commit that closed this issue Oct 26, 2011
@minrk minrk fix inappropriate str.replace in completer.expand_user
The replacement could catch extra matches, mangling the tilde_val.

This uses slicing instead, to prevent multiple replacements.

closes gh-869
2d60716
@minrk minrk closed this in 2d60716 Oct 26, 2011
@minrk
IPython member
minrk commented Oct 26, 2011

%run and %cd have special completers loaded from completerlib. The bug was a tiny one-liner in completer.expand_user, that makes an inappropriate call to str.replace, which doesn't take into account the fact that what it's replacing can occur more than once (e.g. it is '/' when expanding '~/', so the tilde_val is 'homeuser' instead of '/home/user'. I fixed it by truncating the path by length, rather than using str.replace.

@fperez
IPython member
fperez commented Oct 27, 2011

Thanks a ton, @minrk!

@mattvonrocketstein mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
@minrk minrk fix inappropriate str.replace in completer.expand_user
The replacement could catch extra matches, mangling the tilde_val.

This uses slicing instead, to prevent multiple replacements.

closes gh-869
3245421
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.