Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Support for TAB in repl #34

Open
avive opened this issue Jun 29, 2021 · 4 comments
Open

Support for TAB in repl #34

avive opened this issue Jun 29, 2021 · 4 comments
Labels
good first issue Good for newcomers

Comments

@avive
Copy link
Contributor

avive commented Jun 29, 2021

Make TAB key behave like SPACE key in repl keyboard input so the auto-suggestor for the current level will be displayed.

So, if TAB is pressed after a command was typed or entered via suggestion, e.g. wallet then treat it as space - enter space and display the correct auto-suggestor (in our example, wallet commands). However, if tab is pressed when an auto-suggestor is open - don't modify anything as tab correctly rotates between all available commands.

@avive avive added the good first issue Good for newcomers label Jun 29, 2021
@Soptq
Copy link
Contributor

Soptq commented Jul 12, 2021

There is a corner case I think we are missing to discuss here: when we press tab for a auto-completion, for example when we press tab with a input of 'wall', go-prompt will automatically insert 'et' to the end of our input. At this moment 'tab' will be treated as "withdraw" or "switch" by go-prompt even though the auto-suggestor is closed, which will cause conflicts with our original intention.

@avive
Copy link
Contributor Author

avive commented Jul 12, 2021

Good point, I think needs to be handled in the following way:

  1. If tab is pressed after some text is entered which is not a valid command at the current completion level then it should work like it does now - open the suggestor floating area with valid suggestion based on user text entry prefix.
  2. If tab is pressed just after a valid command was entered by the user (by typing or by completing from a suggestion) it should be treated as space (add space to the user input) and open the suggestor floating area for the next level of suggestions so user can select next-level suggestion or type it.

Makes sense?

@Soptq
Copy link
Contributor

Soptq commented Jul 12, 2021

Yeah, but in order to achieve this, perhaps we need to maintain a fork of go-prompt since to my best knowledge there is no such a callback in go-prompt that capable of retrieving variables we need here. Nevertheless, I will do more research of it.

@avive
Copy link
Contributor Author

avive commented Aug 2, 2021

I see. Maybe there are better prompt libs out there that we can use?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants