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 /.
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.
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.
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.
%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.
Thanks a ton, @minrk!