dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.84k stars 666 forks source link

Incorrect intellisense autocomplete in LINQ lambda expression #4269

Closed jcjveraa closed 2 days ago

jcjveraa commented 3 years ago

Issue Description

Intellisense 'intervenes' with an unwanted variable type suggestion when I try to write a LINQ lambda expression with Aggregate, or any other similar usage.

Steps to Reproduce

  1. Declare a variable and start writing a LINQ aggregation, adding initial parenthesis for the lambda expression, e.g. var aggList = MyList.Aggregate(())
  2. Type the character x

Expected Behavior

Intellisense recognizes that I try to create a lambda expression with an 'implicitly typed' (unsure if I'm saying that correctly) variable named x, and perhaps some others. As it is a 'new' variable it should offer no suggestions for autocompletion (or perhaps the appropriate number of 'anonymous variables' for the particular function, e.g. two in this case).

Actual Behavior

Intellisense 'jumps in' and suggests a X500DistinguishedName auto completion. I need to press escape (or anything else to cancel Intellisense) to cancel this behavior.

When I press enter, some other helper function adds using System.Security.Cryptography.X509Certificates; (which makes sense if I had wanted to use the X500DistinguishedName)

Logs

AdventOfCode2020-1607247193476

OmniSharp log

not applicable

C# log

not applicable

Environment information

VSCode version: 1.51.1 C# Extension: 1.23.6

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.403 Commit: 9e895200cd Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.403\ Host (useful for support): Version: 3.1.9 Commit: 774fc3d6a9 .NET Core SDKs installed: 3.1.100 [C:\Program Files\dotnet\sdk] 3.1.403 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |addDocComments|stevencl|0.0.8| |anaconda-extension-pack|ms-python|1.0.1| |Angular-BeastCode|Mikael|10.0.3| |beautify|HookyQR|1.5.0| |change-case|wmaurer|1.0.0| |chronicler|arcsine|0.1.8| |cpptools|ms-vscode|1.1.3| |csharp|ms-dotnettools|1.23.6| |csharp2ts|rafaelsalguero|0.0.24| |debugger-for-chrome|msjsdiag|4.12.11| |dotenv|mikestead|1.0.1| |eppz-code|eppz|1.2.52| |html-css-class-completion|Zignd|1.19.0| |json-tools|eriklynd|1.0.2| |jupyter|ms-toolsai|2020.11.399280825| |language-pde|Tobiah|1.4.6| |minify|HookyQR|0.4.3| |mustache|dawhite|1.1.1| |ng-template|Angular|0.1100.2| |npm-intellisense|christian-kohler|1.3.1| |php-cs-fixer|junstyle|0.1.157| |php-docblocker|neilbrayfield|2.1.0| |php-intellisense|felixfbecker|2.3.14| |phpcs|ikappas|1.0.5| |python|ms-python|2020.11.371526539| |rainbow-csv|mechatroner|1.8.0| |trailing-spaces|shardulm94|0.3.1| |typescript-hero|rbbit|3.0.0| |vscode-apache|mrmlnc|1.2.0| |vscode-arduino|vsciot-vscode|0.3.4| |vscode-eslint|dbaeumer|2.1.13| |vscode-npm-script|eg2|0.3.13| |vscode-pylance|ms-python|2020.12.0| |vscode-todo-highlight|wayou|1.0.4| |vscode-yaml|redhat|0.13.0| |vscodeintellicode|VisualStudioExptTeam|1.2.10| |xml|DotJoshJohnson|2.5.1|;
stewartadam commented 3 years ago

Also running into this, very annoying to always have to mash escape when writing lambdas.

XUWeijiang commented 3 years ago

It has been long time. Any progress on this? BTW, I have set "editor.acceptSuggestionOnCommitCharacter" to false to work around this problem.

JoeRobich commented 2 days ago

The suggestion for a type is correct at that location as it could be an implicitly typed lambda or it could not be. Intellisense completions have been improved for this scenario to no longer automatically complete the suggestion. It would be necessary to press Tab instead of space or comma for instance.