smrepl
smrepl copied to clipboard
Support for TAB in repl
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.
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.
Good point, I think needs to be handled in the following way:
- 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.
- 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?
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.
I see. Maybe there are better prompt libs out there that we can use?