Closed Bug 879028 Opened 11 years ago Closed 10 years ago

Tab and Shift+Tab should cycle through autocompletions

Categories

(DevTools :: Console, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: fitzgen, Assigned: jwalker)

References

(Blocks 1 open bug)

Details

(Whiteboard: [autocomplete])

When typing in the console and the autocompletion pops up, I should be able to cycle forward through the suggestions with Tab and backwards with Shift+Tab.
Whiteboard: [autocomplete]
This is different from what Chrome's console does. Tab seems to work in our case in the same way as it does for them. Still, the idea makes sense to me - Tab/Shift-Tab should cycle through suggestions.
OS: Mac OS X → All
Priority: -- → P3
Hardware: x86 → All
Should be able to tab, and then just start typing, no need to explicitly say we are done with autocompletion by hitting enter or anything.

http://www.youtube.com/watch?v=LbUCQAYIB0o
Nick, I'm not clear on the key sequences there. I see TAB as the 'accept completion proposal' character, but you're using it as a 'get proposal' character?

Whatever we decide, I think it makes sense to put the fix into JSTerm.
In the video, I type "window.create" and then the autocompletion suggestions automatically pop up. I cycle through them by hitting shift repeatedly. Each time a suggestion is selected, it is inserted into the text. When I have selected the suggestion I want, I can just continue typing without hitting any key to "accept" the suggestion because it is already in my text.
Sorry hitting TAB repeatedly
(In reply to Nick Fitzgerald [:fitzgen] from comment #4)
> In the video, I type "window.create" and then the autocompletion suggestions
> automatically pop up. I cycle through them by hitting shift repeatedly. Each
> time a suggestion is selected, it is inserted into the text. When I have
> selected the suggestion I want, I can just continue typing without hitting
> any key to "accept" the suggestion because it is already in my text.

I am with this behavior to. Although a slight modificaiton (I don't know if Nick already meant this or not)

when you have typed "window.create" and the popup appears like:

window.create|___________
      |createElement    |
      |createWhimsy     |
      |createHorseJS    |
      -------------------
the first entry can be pre entered for you, but in selection, such that if you want to type anything else, then go ahead and type it, like :

window.create[Element]___
      |createElement    |
      |createWhimsy     |
      |createHorseJS    |
      -------------------

text in [] is selected.

Now if the user presser TAB key, we remove the selection from the "Element" string while still keeping the popup open, highlighting the first entry from the popup and cursor at the end of the line like :

window.createElement|____
      |[createElement]  |
      |createWhimsy     |
      |createHorseJS    |
      -------------------

text in [] is highlighted.

Now if the user presses TAB again, then the "Element" string gets replaced with "Whimsy" string, still without selection and the "createWhimsy" gets highlighted like :

window.createWhimsy|_____
      |createElement    |
      |[createWhimsy]   |
      |createHorseJS    |
      -------------------

This way, the user can simply type "." to carry on with the expression and then the popup will go away (and actually return with newer suggestion set) like :

window.createWhimsy.|__________
                   |__proto__  |
                   |prototype  |
                   -------------


and so on.
(In reply to Nick Fitzgerald [:fitzgen] from comment #4)
> In the video, I type "window.create" and then the autocompletion suggestions
> automatically pop up. I cycle through them by hitting shift repeatedly. Each
> time a suggestion is selected, it is inserted into the text. When I have
> selected the suggestion I want, I can just continue typing without hitting
> any key to "accept" the suggestion because it is already in my text.

What happens if you type ``window.screen<RETURN>``? (window.screen is legal, as it window.screenX)

Or, more broadly, do you have to watch the screen to know what will happen when you press <RETURN>, <LEFT> or <RIGHT>?
(In reply to Joe Walker [:jwalker] from comment #7)
> (In reply to Nick Fitzgerald [:fitzgen] from comment #4)
> > In the video, I type "window.create" and then the autocompletion suggestions
> > automatically pop up. I cycle through them by hitting shift repeatedly. Each
> > time a suggestion is selected, it is inserted into the text. When I have
> > selected the suggestion I want, I can just continue typing without hitting
> > any key to "accept" the suggestion because it is already in my text.
> 
> What happens if you type ``window.screen<RETURN>``? (window.screen is legal,
> as it window.screenX)

In that case, "screen" text would already by the first suggestion, infact, you will have to press TAB key to go to "ScreenX"
RETURN always does what it otherwise would. If you are in the console, it submits the text to be evaluated. If you are in the scratchpad, it would add a newline.

Same with LEFT and RIGHT: they always do what they would whether or not the autocompletion suggestions are present or not.
(In reply to Nick Fitzgerald [:fitzgen] from comment #9)
> RETURN always does what it otherwise would. If you are in the console, it
> submits the text to be evaluated. If you are in the scratchpad, it would add
> a newline.
> 
> Same with LEFT and RIGHT: they always do what they would whether or not the
> autocompletion suggestions are present or not.

So, without looking at the screen, I type ``window.create<RETURN>``, do I get what I expect?, which is to say:

"window.create
"
(In reply to Joe Walker [:jwalker] from comment #10)
> (In reply to Nick Fitzgerald [:fitzgen] from comment #9)
> > RETURN always does what it otherwise would. If you are in the console, it
> > submits the text to be evaluated. If you are in the scratchpad, it would add
> > a newline.
> > 
> > Same with LEFT and RIGHT: they always do what they would whether or not the
> > autocompletion suggestions are present or not.
> 
> So, without looking at the screen, I type ``window.create<RETURN>``, do I
> get what I expect?, which is to say:
> 
> "window.create
> "

Yes
If any of you are interested, this is what I (and Nick) were talking about : http://scrapmac.github.io/aulx/
(In reply to Girish Sharma [:Optimizer] from comment #12)
> If any of you are interested, this is what I (and Nick) were talking about :
> http://scrapmac.github.io/aulx/

[except that the UP and DOWN keys also behave as TAB and SHIFT TAB in that demo]
Yes, that feels great to me (except for the arrow keys)
Assignee: nobody → rFobic
Assignee: rFobic → nobody
Assignee: nobody → jwalker
Status: NEW → ASSIGNED
Style editor now has autocopmletion. But there cycling is allowed *only* via TAB/SHIFT-TAB . UP and DOWN will close the popup and move the caret instead.

Is this what you wanted Nick in your comment 14 ?
(In reply to Girish Sharma [:Optimizer] from comment #15)
> Style editor now has autocopmletion. But there cycling is allowed *only* via
> TAB/SHIFT-TAB . UP and DOWN will close the popup and move the caret instead.
> 
> Is this what you wanted Nick in your comment 14 ?

Perfect.
After implementing the key binding as discussed in this bug in the Style Editor's autocopmletion popup, everybody is complaining about the missing UP/DOWN and ENTER keybinds.

After all, every other code editor has those key bindings too.

Also, it turns out that people are ready to press Escape and Enter to go to next line (when popup is open) rather than not having Enter key insert first result.

I think that this bug should be Wontfixed by popular demand.
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Resolution: FIXED → WONTFIX
(At this point, I was just asking for an opinion. Not to actually wontfix it. I would have done it myself otherwise :) )
Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
(In reply to Girish Sharma [:Optimizer] from comment #17)
> After implementing the key binding as discussed in this bug in the Style
> Editor's autocopmletion popup, everybody is complaining about the missing
> UP/DOWN and ENTER keybinds.
> 
> After all, every other code editor has those key bindings too.
> 
> Also, it turns out that people are ready to press Escape and Enter to go to
> next line (when popup is open) rather than not having Enter key insert first
> result.
> 
> I think that this bug should be Wontfixed by popular demand.

Sure, +1 for wontfixing. As discussed on twitter, even if we think we have something cooler than the 'standard', *not* using the standard interaction costs us by surprising people.
Status: REOPENED → RESOLVED
Closed: 10 years ago10 years ago
Resolution: --- → WONTFIX
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.