dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.05k stars 4.04k forks source link

Provide option to disable declaration completion name suggestions #22294

Closed dpoeschl closed 4 days ago

dpoeschl commented 7 years ago

Feedback issues: https://developercommunity.visualstudio.com/content/problem/115612/need-opt-out-setting-for-new-suggest-variable-name.html https://developercommunity.visualstudio.com/content/problem/92721/please-provide-an-option-to-disable-the-new-intell.html

sharwell commented 7 years ago

@dpoeschl We should reach out to these users and gather feedback regarding how our suggestions are currently differing from what they want, which we can aggregate into a proposal for a feature that better meets the needs of a wider and varying audience.

I don't object to the option, but it does seem strange that it would interfere considering it's not selected by default. Maybe get more feedback on what the issue is before deciding to add an option?

Mitch-Connor commented 7 years ago

@sharwell My problem with the suggestions had to do with their interaction with snippets (as did several other commenters from what I saw). Specifically when using a multi-part snippet, the normal method of jumping to the next replacement parameter is pressing TAB, which with name suggestions (or intellisense in general) is taken as confirmation that the suggestion is desired. This effectively means that for multi-part snippets name suggestions are selected by default. This either means hitting ESC before tabbing to the next part or using the arrows/mouse to navigate manually to the next piece.

Technically this has also been the behavior for type completion in snippets, but since the list of possible types is a finite list and the type is usually already in scope, accepting the suggestion is a sensible default behavior.

Speaking for myself, I see two solutions that would work for me (in order of preference):

1) Stop the tab key from accepting the name suggestion in code snippets only, but continue to have the tab key accept type suggestions in code snippets (i.e. don't just altogether disable tab accepting suggestions anywhere in a snippet)

2) Allow name suggestions to be fully disabled

rchande commented 7 years ago

@Mitch-Connor We are currently working on a change that disables name completion while snippets are active, which should address (1) for you. Apart from interfering with navigation between snippet fields, is name completion causing any specific problems for you?

bennbenson commented 7 years ago

@sharwell For me, it interrupts my typing most when I use tab to skip past the closing parenthesis using automatic brace completion. The problem is simply that it inserts the outlined-but-not-selected item when pressing tab. I believe that's the same reason that snippets are no longer behaving as expected.

Ideally, I'd never see the suggestion list again. It's just noise to me. I type fast and I'm accustomed to typing what I want. I've even found myself typing a name before even noticing that it was in the list. The transition from typing to selection / list navigation at that point would slow me down, even when one of the suggestions is what I want.

For those who want to use it, though, I suggest requiring that the item be selected before tab will insert the item. That way the feature is still available but it doesn't interrupt other features like automatic brace completion and snippets.

bennbenson commented 7 years ago

@rchande Please consider my suggestion so people can still use the feature when snippets are active if they want.

rchande commented 7 years ago

@bennbenson Thanks for pointing out that interaction between completion and automatic brace completion. I didn't realize that pressing tab to advance past the close brace was a feature. I assume you're hitting that while typing a parameter list? Name completion is already set to deliberately only insert text on tab, but clearly that doesn't help with the case you mentioned.o

bennbenson commented 7 years ago

@rchande Yes. It only works if the cursor is right next to the tracked parenthesis but that's often the case for me, having just typed the name of the last parameter.

Again, the first item is not selected, just outlined (like the focus rectangle in GDI-based controls), so I would expect that tab would not insert the item, but it does. That's the core of my frustration. If I press an arrow key to select an item in the list, I would expect tab to insert that selection -- and it does. But failing that, tab shouldn't insert anything because I didn't deliberately select anything. And so, the next context to consider is the tracked closing parenthesis and it should skip that like it has since 14.0/2015 (and, with the Productivity Power Tools extension installed, going back at least as far as 2010).

Mitch-Connor commented 7 years ago

@rchande Nope, snippet fields are the only place where I personally have encountered an issue with them, but like you I had no idea about the feature @bennbenson mentioned. I'd also agree that I have no problem with the name suggestion popup showing up in snippets, it should just require explicit selection before tab inserts them.

sharwell commented 7 years ago

...use tab to skip past the closing parenthesis using automatic brace completion...

My entire team did not know this existed. 😆

@Mitch-Connor @bennbenson Thank you both for taking time to explain everything. We were already on the same page for providing an option, but hopefully we can use the additional details to craft an experience that's even better.

bcreswell commented 7 years ago

I think its great that more features around style suggestions and naming suggestions are being added. I know there are plenty of users that appreciate them. Also am completely ok with fact that they get turned on by default.

But personally i find it annoying when it is suggesting i do something one way or another. Most of these features i have found settings to turn them off (after extensive googling to find them). Would really appreciate a way to turn off the 15.3 naming suggestions too. Even if it guessed the right name 100% of the time, it is still annoying. For a split second my brain thinks its an autocomplete popup.

Whenever there is a new VS update available i am very hesitant to take it because i know it will likely result in a lot of effort on my part to get VS back to working the way i want (trying to find the new settings to turn off, or in this case having to submit feedback to justify why the settings should exist). I would be much more likely to just take the VS update whenever it was available if, after the update completed, there was a message box describing the new features with check boxes to let me opt out right there on the spot.

Some stubborn users (like me) just appreciate a more minimalist IDE. Thanks for accepting feedback from the community!

Pilchie commented 7 years ago

My entire team did not know this existed.

Doh! @DustinCampbell and I knew this exsited, and @balajikris too...

mhlavacek commented 7 years ago

As one of the users to responded to the issues linked above, I wanted to throw my feedback in here as well.

I agree that the naming suggestions should be something a user can turn on or off. I can't think of a time I would ever want my IDE to suggest a variable name for me because the name that I choose will have cohesion to whatever class or method I am declaring it in.

More often or not, when the name suggestion flyout opens, it usually just prepends the word "Get" in front of whatever type I've declared... which isn't a very good suggestion for a property name anyways.

My frustration is how this new feature conflicts with snippet usage. To reiterate my example from the posted links above...

"In a C# class, create a new property.in my exaple, I typed out "public T MyProperty" then hit space. In an attempt to try and execute a custom snippet with a shortcut "gs", when I hit Tab... the characters "GetT" are put in it's place since that was the only item in the "Suggested Name" flyout."

I have attached the screenshots I linked to here as well.

Honestly I don't really see this feature as being useful. I want my IDE to get out of my way and to stay as fast as possible. I know what I want to name my properties and variables most of the time. If I don't, I just go back and refactor them later. As a workaround, I need to hit the escape key to close the flyout, then type my snippet keyword, then hit tab to execute the snippet. It's pretty clumsy and it hinders productivity big time.

My vote would be to get rid of the feature completely but if you absolutely have to keep it around for some reason, then please allow developers to turn this feature off separate from intellisense in general.

Thank you for your time! Matthew

vs - suggest name issue 2 vs - suggest name issue 1

dpoeschl commented 7 years ago

See also: https://developercommunity.visualstudio.com/content/problem/116474/recent-intellisense-update-attempts-to-auto-comple.html

pzahra commented 7 years ago

Honestly, this seems to me like the kind of feature someone just decided to put in because it sounded cool without considering whether it was actually useful or what the consequences would be. Naming a property its own type is a rare occurrence, prefixing Get to it makes no sense, and you'd be hard pressed to figure out from the context of code that hasn't been written yet what the variable is going to be used for.

sharwell commented 7 years ago

@pzahra It seems to vary by the kind of application. In some code bases the current prediction algorithm is correct more often than not (including some very large code bases). Naturally the goal with the feature is expanding the number of projects which fall into the latter set. :smile:

Camuvingian commented 7 years ago

What's happening with this - it is killing me.

sharwell commented 7 years ago

@Camuvingian The option to disable the feature altogether should be available starting in 15.5 Preview 2. The other part of the fix - making the feature work when snippets are active - is not yet completed.

CyrusNajmabadi commented 7 years ago

Honestly, this seems to me like the kind of feature someone just decided to put in because it sounded cool without considering whether it was actually useful

It's useful to me. I use it for the majority of my names :)

CyrusNajmabadi commented 6 years ago

Cascade of useless and annoing windows and popup-menus appears. Pressing key (on keyboard) causes choosing of useless menu items that trashes source code.

@MyNameIsHidden Can you provide a screenshot/gif showing what you're referring to? Thanks!

CyrusNajmabadi commented 6 years ago

@MyNameIsHidden What editor are you using?

MyNameIsHidden commented 6 years ago

Well. I'm terebly sorry... It seems that google followed me to wrong community forum. I use Visual Studio for Mac. Deleting my posts... Sorry for bothering

CyrusNajmabadi commented 6 years ago

:) Good luck!

sharwell commented 6 years ago

@MyNameIsHidden Visual Studio for Mac uses several features from this repository, so it's not necessarily the wrong place to file it. We work in a whole bunch of places so it's easy for users to get them mixed up. If something ends up in the wrong place we can help get it moved too. 😄

miloush commented 6 years ago

Did the option to turn the name suggestions off stopped the fix for code snippets? I find the feature useful and would be happy to keep it on but it as mentioned above it always deletes what I write when I press Tab to move to the next snippet part.

ehelin commented 5 years ago

I see the option for C#....but there appears to be no show name suggestions for JavaScript in visual studio. Is it possible to turn of the name suggestions without disabling intellisense?

ScissorSnips commented 4 years ago

Surfacing a workaround by mhlavacek

hit the escape key to close the flyout

An easy option might be to let us use a different hotkey/shortcut to move to the next portion of the snippet, instead of tab. Or have the snippet TAB-listener take priority over the intellisense listener (or however VS works internally) and consume the event. Or maybe only pull the value from intellisense if we've hit an arrow key to explicitly make a selection.

CyrusNajmabadi commented 4 days ago

Closing as resolved.