xonsh / xonsh

:shell: Python-powered shell. Full-featured and cross-platform.
http://xon.sh
Other
8.43k stars 641 forks source link

Tab completion happens after command invocation #2770

Open jaraco opened 6 years ago

jaraco commented 6 years ago

xonfig

jaraco.functools master $ xonfig

+------------------+----------------------+
| xonsh            | 0.7.3                |
| Git SHA          | 55d69ee6             |
| Commit Date      | Aug 11 10:22:24 2018 |
| Python           | 3.7.0                |
| PLY              | 3.9                  |
| have readline    | True                 |
| prompt toolkit   | 2.0.4                |
| shell type       | prompt_toolkit2      |
| pygments         | None                 |
| on posix         | True                 |
| on linux         | False                |
| on darwin        | True                 |
| on windows       | False                |
| on cygwin        | False                |
| on msys2         | False                |
| is superuser     | False                |
| default encoding | utf-8                |
| xonsh encoding   | utf-8                |
| encoding errors  | surrogateescape      |
+------------------+----------------------+

Expected Behavior

Tab completion should happen before the command is processed for invocation.

Current Behavior

I started a new xonsh session, and before the session finished processing my .profile, I typed my command cd ~/m/jaraco.func^t^n. In the terminal, I see the following:

cd ~/m/jaraco.func
~ $ cd ~/m/jaraco.functools/
cd: no such file or directory: /Users/jaraco/m/jaraco.func
~ $ cd ~/m/jaraco.functools
jaraco.functools master $

You can see where xonsh did expand the command fully, but because I hit enter before the tab completion had processed, the command was invoked with that partial command-line.

For community

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

melund commented 6 years ago

I think this may be an unintended side effect of the async tab-completion in prompt_toolkit 2. Maybe there is a way to either wait for or cancel tab-completions when the user invokes the command.

Otherwise, we can try to make tab-completion blocking again.

scopatz commented 6 years ago

Weird, thanks for reporting @jaraco!

jaraco commented 6 years ago

Today I experienced this even after the prompt had rendered (and thus profile loaded):

~ $ cd ~/yg/public/velociraptor/
cd: no such file or directory: /Users/jaraco/yg/public/vel

this may be an unintended side effect of the async tab-completion in prompt_toolkit

You're probably right. I don't remember encountering this issue before I installed prompt toolkit about two weeks ago.

scopatz commented 6 years ago

@jonathanslenders - is there a way to cancel tab-completion once the user has hit enter?