ConsoleBundle icon indicating copy to clipboard operation
ConsoleBundle copied to clipboard

Autocomplete: Tab behavior

Open vicb opened this issue 12 years ago • 7 comments

It would be great that tab stops after the first ":" where different commands are possible.

IE after "doct", tab should stop on "doctrine:"

vicb avatar Feb 10 '13 12:02 vicb

This is how I implemented it in a really early version but I did not like it because there is already a command selected in the suggestion list so when you press tab I would assume this selected command is used.

When I type "doc" and the first suggestion is "doctrine:cache:clear-metadata" and it is selected (given the behavior you suggest is implemented) I would need to press tab 3 times.

One possibility would be not to focus a suggestion by default and only use your suggested behavior when no suggestion is selected but I assume that would not be very intuitive because there would be more different cases of behavior.

Do you have a concrete case in mind in which the behavior you suggest would be easier to use? I mean when typing "doc" you already see all the doctrine commands. I assume it is about this case:

you want to use the "doctrine:cache:clear-result" command and want to type: "doc"[tab]"ca"[tab]"clear-result" so you save the time writing "trine" and "che".

But the much easier way would be to just write "clear-result" in the beginning as the autocompletion does not force you to start on the left side of the command.

laszlokorte avatar Feb 10 '13 12:02 laszlokorte

"doctrine:generate:entities" could be a good example. If I wan to use this comand, I would like to be able to type:

  • "doc"
  • tab
  • "ge"
  • tab
  • "ent"
  • tab

One possibility would be not to focus a suggestion by default and only use your suggested behavior when no suggestion is selected but I assume that would not be very intuitive because there would be more different cases of behavior.

:+1: for this. I assume that you would rarely use the first command anyway (especially true when you have a lot of commands, like in the "doctrine" ns).

I think the most "difficult" part of the PR it to avoid unambiguous stops:

  • "namespace:sub:abc"
  • "namespace:sub:def"

"nam" + tab should autocomplete to "namespace:sub:" as this is not ambiguous.

vicb avatar Feb 10 '13 13:02 vicb

What should happen wenn I type: "c" tab

I could autocompelete to "cache:" or "config:" or "container:"

Currently the autocompletion list also shows all the doCtrine commands as suggestion too.

laszlokorte avatar Feb 10 '13 19:02 laszlokorte

Ideally I think you should stop autocompleting where the completion becomes ambiguous (multiple solutions). This would match the behavior of terminals. To continue either select a (sub)command or type more letters.

That's would be the best thing to have imo but something different would be ok if this makes the code too complicated.

Laszlo Korte [email protected] wrote:

What should happen wenn I type: "c" tab

I could autocompelete to "cache:" or "config:" or "container:"

Currently the autocompletion list also shows all the doCtrine commands as suggestion too.


Reply to this email directly or view it on GitHub: https://github.com/CoreSphere/ConsoleBundle/issues/9#issuecomment-13359125

vicb avatar Feb 10 '13 19:02 vicb

Ok...

I have started implementing this a separate branch: https://github.com/CoreSphere/ConsoleBundle/tree/alternate-autocomp

When the input is ambiguous the old behavior is used: focus first item in autocompletion list

When the input is the prefix of exactly one namespace: no suggestion is focused and pressing tab triggers the autocompletion up to the next ":"

laszlokorte avatar Feb 10 '13 20:02 laszlokorte

I won't have time to look at it before next friday.

On 02/10/2013 09:37 PM, Laszlo Korte wrote:

Ok...

I have started implementing this a separate branch: https://github.com/CoreSphere/ConsoleBundle/tree/alternate-autocomp

When the input is ambiguous the old behavior is used: focus first item in autocompletion list

When the input is the prefix of exactly one namespace: no suggestion is focused and pressing tab triggers the autocompletion up to the next ":"

— Reply to this email directly or view it on GitHub https://github.com/CoreSphere/ConsoleBundle/issues/9#issuecomment-13360571..

vicb avatar Feb 10 '13 21:02 vicb

Is this still active? If not, I'd suggesting closing.

In case of interest, PR is welcomed of course.

TomasVotruba avatar Aug 24 '15 20:08 TomasVotruba