dundalek/closh

[BUG] Display and input overlap with tab-completion

Closed this issue · 11 comments

REPRODUCTION

  1. Run closh-zero.jar
  2. Type in a base directory like ~/
  3. Press the TAB key
  4. Start typing the prefix of a listed dir

Expected

  • Cursor should remain at the end of where I typed (just after ~/)
  • Input should remain unchanged
  • Tab completion results visually organized

Actual

  • Cursor moves to beginning of line

  • Typing the prefix of a completion overwrites the initial input

  • Completions are combined or characters are missing

  • Completions are listed in a nested, unpredictable format

    closh_tab_completion

Environment

Param Value
Operating System: OS X Mojave (10.14)
Parent Shell: ZSH
Closh Version: 0.3.2
Terminal: iTerm 2

Notes

That looks strange indeed. Does it happen every time or only sometimes?

I sometimes get strange behavior when I resize the terminal window but unfortunately I haven't been able to observe any patterns. Did you maybe resize the terminal?

Could you try a different terminal to see what the behavior is there?

Happens every time. I’ll try a different terminal and see what happens.

Another pointer might be to try to run rebel-readline and see how completions behave there (closh uses rebel-readline internally). I don't run a Mac so I can't unfortunately test these myself.

Just tried both. Same thing happened when using default OS X Terminal:

screen shot 2018-12-12 at 11 48 03 am

Rebel readline seemed to work correctly:

screen shot 2018-12-12 at 11 49 33 am

clojure -Sdeps "{:deps {com.bhauman/rebel-readline {:mvn/version \"0.1.4\"}}}" -m rebel-readline.main

Great, that helped narrow it down a lot.

I think I found the issue. Closh invokes existing shells for completions. It first tries fish, then zsh and lastly fallbacks to bash. In your case it seems to them from zsh, but it seems that zsh returns some special characters that move the terminal into inconsistent state. I have fish installed so I haven't noticed this before.

In order to fix this I need to improve how the input from zsh gets handled.

In the meantime a temporary workaround for you could be to install the fish shell :)

The fix for this is now in master. While I am at it I will try to tackle #112 and will publish a release after that.

Confirming that running it within fish shell did fix tab-completion. It even works when using bash. I'll try to test those environments if anything comes up again.

Also, you may have just converted me to fish shell*


[*] Fish shell until or under closh of course 😄

Haha, nice one 😄 I switched to fish and used it for some while before I started working on closh. I think it has the best user interface of all and I would like to make closh feel as smooth (or better) one day.

Yeah, fish is a really rich experience. It's a very good benchmark for Closh :)

After playing more with Closh, this behavior does occur even when setting it directly as my default shell. Will this upcoming release fix that?

It took a bit longer but v0.3.3 is now published and it includes a fix for this issue.

Appears fixed now, great job!