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

Implement "Suggestion Mode" from Visual Studio #139825

Closed
macintacos opened this issue Dec 28, 2021 · 22 comments
Closed

Implement "Suggestion Mode" from Visual Studio #139825

macintacos opened this issue Dec 28, 2021 · 22 comments
Assignees
Labels
feature-request Request for new features or functionality on-testplan suggest IntelliSense, Auto Complete
Milestone

Comments

@macintacos
Copy link

macintacos commented Dec 28, 2021

In Visual Studio, there is a mode called "Suggestion Mode" that is described here in MS's documentation. This functionality is more succinctly described in this blog post. Basically, I would like for suggestions to be shown, but none "selected" until I actually wish to use them.

This has been brought up in several issues (at the very least #85768, #67698, #33725). I wanted to open a new issue to have the VSCode potentially reconsider this, since after reading one of the VSCode bot's links, it appears that older issues are unsubscribed by the team - it would be great to have this implemented.

Editing with some minor clarifications I provided in my comment below:

The ideal scenario that I personally am trying to have in VSCode is:

  1. I type something into an editor and I get suggestions.
  2. As I get those suggestions, none are "selected" until I hit "tab" or arrow-down the list of suggestions (I personally use "tab" to go through the suggestion list, but the point is that it should be an intentional choice for me to navigate through the list).
  3. At this point, I decide what I want to do. If I intentionally navigate into the suggestion list and I have decided on an item I want to insert, I hit "enter" and VSCode completes the selection into the editor. If I don't navigate into this list, "enter" will just insert a line break.
@imericxu
Copy link

I’d like to add that from working in Neovim, I found it very intuitive to explicitly select and cycle through auto-completion suggestions with Ctrl + n and Ctrl + p or tabbing then accept with Enter. Currently, I’m resorting to accepting with the Tab key alongside the Vim extension.

@haoadoreorange
Copy link

haoadoreorange commented Apr 5, 2022

@macintacos does editor.acceptSuggestionOnEnter solve the problem ?

@trivial-zero
Copy link

@macintacos does editor.acceptSuggestionOnEnter solve the problem ?

No, it is still selected

@haoadoreorange
Copy link

I mean it's still selected but enter make a new line, so shouldn't that be good ?

@macintacos
Copy link
Author

@haoadoresorange no. I still want "enter" to be how completion items are chosen after navigating to them in the list. I just don't want anything in the quick suggestion list selected until I navigate into the list.

The ideal scenario that I personally am trying to have in VSCode is:

  1. I type something into an editor and I get suggestions.
  2. As I get those suggestions, none are "selected" until I hit "tab" or arrow-down the list of suggestions (I personally use "tab" to go through the suggestion list, but the point is that it should be an intentional choice for me to navigate through the list).
  3. At this point, I decide what I want to do. If I intentionally navigate into the suggestion list and I have decided on an item I want to insert, I hit "enter" and VSCode completes the selection into the editor. If I don't navigate into this list, "enter" will just insert a line break.

Hopefully that adds some clarity to this feature request.

@haoadoreorange
Copy link

@macintacos I see, maybe add this to the original post above ?

@macintacos
Copy link
Author

Sure, I've updated it.

@user72356
Copy link

user72356 commented Sep 2, 2022

Isn't that exactly how Visual Studio (2019) works? At least that's what I remember from my VS days. My muscle memory tells me so.

@imericxu
Copy link

imericxu commented Sep 2, 2022

@user72356 VS and VSCode are two different programs.

@user72356
Copy link

user72356 commented Sep 2, 2022

@user72356 VS and VSCode are two different programs.

So what? You expect people not to compare feature sets when they know something that works better elsewhere? Especially another MS product. You even made a comparison with Neovim youself, so what is your point?

@imericxu
Copy link

imericxu commented Sep 2, 2022

My bad, I misunderstood it as you saying the current functionality is expected, especially since you have a random username.

@jrieken jrieken self-assigned this Dec 7, 2022
@jrieken
Copy link
Member

jrieken commented Dec 7, 2022

This actually started with #151336

@macintacos
Copy link
Author

Never thought I'd see the day - this seems to work pretty much exactly the way that I want it to, this is great!

For those who can't be bothered to open that issue, the setting is:

  "editor.suggest.selectQuickSuggestions": false,

It'll present as "disabled", but that appears to be on purpose. It still works.

@macintacos
Copy link
Author

macintacos commented Dec 9, 2022

Actually... not quite. Thought it was working, but it doesn't seem to work the way I have selections set up with my keybindings.

Currently, as stated in the description, I use tab/shift+tab to navigate the suggestion list. This is set up like this:

  {
    "key": "tab",
    "command": "selectNextSuggestion",
    "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
  },
  {
    "key": "shift+tab",
    "command": "selectPrevSuggestion",
    "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
  }

With "editor.suggest.selectQuickSuggestions": false, the suggestion list isn't selected (great!) but tab doesn't seem to select the first item in the list and allow me to navigate through the list until I dismiss. Am I just missing a keybind/when-clause/command combination now?

@jrieken
Copy link
Member

jrieken commented Dec 9, 2022

Yeah, there is a new focusSuggestion command which puts focus into the list first. By default it is bound to the trigger keybindings, e.g cmd+space etc. You should be able to configure it.

registerEditorCommand(new SuggestCommand({
id: 'focusSuggestion',
precondition: ContextKeyExpr.and(SuggestContext.Visible, SuggestContext.HasFocusedSuggestion.negate(), ContextKeyExpr.equals('config.editor.suggest.selectQuickSuggestions', false)),
handler: x => x.focusSuggestion(),
kbOpts: {
weight: weight,
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyCode.Space,
secondary: [KeyMod.CtrlCmd | KeyCode.KeyI],
mac: { primary: KeyMod.WinCtrl | KeyCode.Space, secondary: [KeyMod.CtrlCmd | KeyCode.KeyI] }
},
}));

@macintacos
Copy link
Author

@jrieken thanks! I'll look into that.

Yeah I'll share what I come up with - I just noticed that it's because it wasn't working when only one item was shown in the suggestion list, because then technically the suggestWidgetMultipleSuggestions would be false in that case (which was causing the default behavior - inserting a tab instead of navigating into the list). Trying to figure it out.

@macintacos
Copy link
Author

Okay yeah adding this seems to make things work the way I expect:

  {
    "key": "tab",
    "command": "focusSuggestion",
    "when": "editorFocus && suggestWidgetVisible"
  },

@jrieken jrieken modified the milestones: Backlog, January 2023 Dec 9, 2022
@tristone13th
Copy link

Never thought I'd see the day - this seems to work pretty much exactly the way that I want it to, this is great!

For those who can't be bothered to open that issue, the setting is:

  "editor.suggest.selectQuickSuggestions": false,

It'll present as "disabled", but that appears to be on purpose. It still works.

Worked for me, thanks!

@jrieken
Copy link
Member

jrieken commented Dec 23, 2022

👋 Attention: for next Insiders (which will be released after the break, #168000) I have renamed the setting to editor.suggest.selectionMode. Also, it is no longer a boolean anymore but allows for more fine grained control when it comes to auto suggest triggered by typing (aka quick suggest) or by trigger-characters.

Screen.Recording.2022-12-23.at.16.39.39.mov

@jrieken
Copy link
Member

jrieken commented Jan 19, 2023

Closing - remaining work should be tackled as separate bugs or polish issues

@jrieken jrieken closed this as completed Jan 19, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 5, 2023
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 on-testplan suggest IntelliSense, Auto Complete
Projects
None yet
Development

No branches or pull requests

9 participants