Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code-completion doesn't use next suggestion on pressing tab multiple times #28215

Closed
DomiR opened this issue Jun 7, 2017 · 18 comments
Closed
Assignees
Labels
feature-request Request for new features or functionality release-notes Release notes issues suggest IntelliSense, Auto Complete verification-needed Verification of issue is requested verified Verification succeeded

Comments

@DomiR
Copy link

DomiR commented Jun 7, 2017

TL;DR the tab key should insert first suggestion, but then cycle through suggestions, replacing the last completion.

Sublime autocompletion can be configured so that when pressing the tab multiple times it will cycle through the autocompletions by inserting the first suggestion (closing the suggestion box), then replacing the suggestion by succeeding ones when pressing tab repeatedly.

Problem description:
Visually:

// e.g. 1. typing`whatI` will render both options in suggestion box
whatI|
      -whatIGet   // => 2. first option will be autocompleted on `tab` closing the suggestion box
      -whatIWant // => 3. on second `tab` this should replace the first (wrong) suggestion

function whatIWant() {}

funciton whatIGet() {}

Textually:

  1. Type whatI
  2. Suggestions will pop up
  3. Wrong suggestion is highlighted
  4. tab to complete wrong suggestion
  5. Suggestions-popup disappears
  6. Still at the end of inserted suggestion press tab again
  7. Wrong suggestion should be replaced by next suggestion in list

Currently the corresponding controllers don't seem to support this, as accepting the current suggestion to my understanding will clear the suggestion list.

https://github.com/Microsoft/vscode/blob/3215f19074d49e32d5ab55203923865910d4d5ca/src/vs/editor/contrib/suggest/browser/suggestController.ts
https://github.com/Microsoft/vscode/blob/794b435b27bcf4a92cc0a6345b97821e3c827dcc/src/vs/editor/contrib/suggest/browser/suggestWidget.ts

How are people getting around having to press arrow-down and arrow-up 🤦‍♂️? I somehow never get the correct suggestion at the top and I quite frankly don't have the most flexible pinky 😢

@jrieken jrieken added feature-request Request for new features or functionality suggest IntelliSense, Auto Complete labels Jun 8, 2017
@andreyorst
Copy link

andreyorst commented Sep 21, 2017

  1. tab to complete wrong suggestion
  2. Suggestions-popup disappears

Yeah, but why close popup on tab?

If your correct suggestion isn't next in the list, and popup is closed you can run into a situation when you rapidly pressed tab key and gone too far in your list, then you could use to go up, but there is no popup so you wil probably change line.
Yes, I know that you can use shift+tab to go backwards in the list, but I think it is better to see list, because it is changing all the time, and you dont need to remember how far your suggestion is.

Well maybe someone dont like the fact that when completion is done, no matter wrong or right one, the list is still there and hovers above the code, hiding it from eyesight, and closing popup after first tab is good for them, but there are other people like me who like the opposite behavior, when the popup is always open until you close it by typing. So there may be an extra option for popup behavior

@Naramsim
Copy link

enter image description here

A nice GIF showing what we can do in Sublime

https://stackoverflow.com/questions/48883721/cycle-to-previous-suggestions-in-vscode

@ryanflorence
Copy link

This isn't exactly a duplicate of #34694, supertab in vim keeps the popup open, and doesn't pop up until you hit tab.

screenflow

Code completion the way VSCode handles it is really disruptive and slower than just typing out what I want :\

@andreyorst
Copy link

andreyorst commented Mar 28, 2018

@ryanflorence well, the main idea of any modern autocompletion system is fuzziness. Thats is, you don't need to scroll through list most of the time. Let me demonstrate this:
fuzzy
At first I typed sii wich gave me some_function_with_name_that_is_not_shorter()
And then I type sul and got some_function__that_has_unnecessary_long_name()

However it is not always possible to match with fuzzy, like here:
image
(Imagine that I need that int variable)
and therefore I likely need to spam a tab key some times (I actually use vim with deoplete, so I can), but again, usually I don't, because like here, it is faster to hit c twice.

BTW not regarding to topic, why supertab? It's not nearly as good as standard vim completion system, and far behind other async plugins like deoplete or neovim-completion-manager, or even that bloated YCM

@davidnorthetal
Copy link

davidnorthetal commented Apr 14, 2018

@andreyorst fuzzy searches are not orthogonal to cycling and I'm quite sure everyone here understands how fuzzy searches work

you fuzzy-search when you know the symbol you're looking for (or have a strong suspicion) but don't want to write it all out yourself
you cycle when you want to explore your options

this issue isn't about fuzzy-searches however, it is about triggering autocomp and cycling, so let's stay ontopic

@andreyorst
Copy link

so let's stay ontopic

ok, you want cycling. I'm not against cycling either. Let me explain myself. I'm against programmers who cycle around after every keypress, browsing kilometers of completion items, just to get single one, wich they even know about, but just because it's so fun to cycle around they will do it. In most cases you need to press one extra key (rarely two) to fuzzy match through hell lot of items in the list, but they will hold Tab and wait until chooser will reach their desired completion item. Thats why vscode completion system is good. It disciplines programmer to use his brain instead of brute force. It is hard to figure out how much more productive you will be if you will not scroll every time, and fuzzy match through.

However cycling may benefit in some cases, when you have to deal with messed codebase, with large classes with tons of fields and methods, and you just want to examine it. The problem is only the fact that arrows used for that.

@jrieken
Copy link
Member

jrieken commented Sep 18, 2018

fyi - I have an implementation this in #58871. It will be behind a setting and disabled by default. Now a remaining question: How should this be called? A need a good name for the setting. Anyone having ideas? @DomiR how does sublime call this?

@jrieken jrieken added this to the September 2018 milestone Sep 18, 2018
@jrieken
Copy link
Member

jrieken commented Sep 18, 2018

sep-18-2018 10-45-51

This is how it works

  • it is only enabled when the suggestion has been accepted with tab
  • it won't work when the accepted suggestion is a snippet
  • when cycling through the alternative suggestions, snippets-suggestions are skipped
  • only the narrowed-down list of suggestions is cycled through (e.g. console.g -> group, groupCollapsed, groupEnd)

@svipas
Copy link
Contributor

svipas commented Sep 18, 2018

@jrieken amazing work!

@DomiR
Copy link
Author

DomiR commented Sep 18, 2018

😍 this is perfection. I loved this feature in Sublime and it would be great to get this into VSCode. You are the best, thank you so much!

They call it "tab_completion", see here: https://www.sublimetext.com/docs/2/tab_completion.html

@jrieken
Copy link
Member

jrieken commented Sep 18, 2018

Hm, we have editor.tabCompletion but that currently on expands snippets and only when the cursor is after a snippet prefix. We can extend that option to be off | onlySnippets | on where todays true maps onto onlySnippets.

@jrieken
Copy link
Member

jrieken commented Sep 19, 2018

This is now in master and will be in tomorrows Insiders build: http://code.visualstudio.com/insiders/!

Try it and let me know what you think. This is how it works

  • the editor.tabCompletion setting has now new values off (was false), onlySnippets (was true), and on for the full tab completion behaviour
  • when tab completion is on it will expand a prefix (when the suggest widget isn't showing)
  • when tab completion is on and no suggestion could be found it will insert \t
  • when tab completion is on it will cycle through other suggestions given the current suggestion has been accepted via tab or was tab-completed

@jrieken jrieken closed this as completed Sep 19, 2018
@svipas
Copy link
Contributor

svipas commented Sep 20, 2018

@jrieken What can I say... It's the best feature, I'm in heaven 😄

I'm using these settings and it feels amazing, no more annoying suggestions popup and I can easily autocomplete my changes by pressing tab.

  "editor.quickSuggestions": false,
  "editor.suggestOnTriggerCharacters": false,
  "editor.tabCompletion": "on",
  "emmet.triggerExpansionOnTab": true,

You did a really great job because it surpassed my expectations, it works perfectly!!! ❤️

@jrieken
Copy link
Member

jrieken commented Sep 20, 2018

Thanks for the nice feedback!

@jrieken jrieken added the verification-needed Verification of issue is requested label Sep 24, 2018
@mjbvz mjbvz added the verified Verification succeeded label Sep 25, 2018
@salmankhann
Copy link

salmankhann commented Oct 3, 2018

since the conversation is happening here, I thought of combining my feedback

@jrieken although the current feature in the Insiders is better than before, I was looking for something a bit different that is implemented in Xcode.

See how tab keeps the IntelliSense open, as well as keeps highlighting matched elements.

443dkek1qmoxy6uulp

@PEZ
Copy link
Contributor

PEZ commented Oct 11, 2018

Is there going to be a when clause context that can detect when the suggestions are in this cycle mode? I am the author of an extension where the tab key reformats enclosing code and that makes this new feature unavailable for my users if they keep the key binding.

Maybe @jrieken knows the answer to my question?

@PEZ
Copy link
Contributor

PEZ commented Oct 11, 2018

I found some contexts in the keybindings for the feature. hasOtherSuggestions, and config.editor.tabCompletion. Couldn't find a way to check if (tabCompletion was off OR no more suggestions available), but I got it reasonably right by just checking for the latter.

@svipas
Copy link
Contributor

svipas commented Oct 12, 2018

Guys, this issue was closed, if you want to ask a feature request or something like that, please open a new issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality release-notes Release notes issues suggest IntelliSense, Auto Complete verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

10 participants