vscode-csharp: Autocomplete often incorrectly replaces typed text

Original issue reported here: https://github.com/Microsoft/vscode/issues/57037 I was asked to refer this issue to the C# extension project instead.

Often, while typing in the editor, when I press space after a word, the editor will replace the perfectly valid code with something invalid. I am currently working in C#, and have this happen frequently with several keywords. Today, I tried the Insiders build as well, but still run into the issue. I have also attached a video of the problem happening.

Some examples:

  • new becomes nameof
  • private becomes partial
  • return becomes ref

bad-autocomplete.zip

Environment data

`dotnet --info` output: .NET Core SDK (reflecting any global.json): Version: 2.1.301 Commit: 59524873d6

Runtime Environment: OS Name: Mac OS X OS Version: 10.13 OS Platform: Darwin RID: osx.10.13-x64 Base Path: /usr/local/share/dotnet/sdk/2.1.301/

Host (useful for support): Version: 2.1.1 Commit: 6985b9f684

.NET Core SDKs installed: 2.1.301 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

VS Code version: 1.26.1 and 1.27.0-insiders C# Extension version: 1.15.2

Steps to reproduce

Type an entire name/keyword, verbatim, in the editor and press the spacebar. It does not always happen, but happens enough to be extremely frustrating and to severely impact my productivity.

Expected behavior

Typed name or keyword matches the top entry in the suggestion list and should not be changed.

Actual behavior

Typed name or keyword changes to an unrelated, and often semantically invalid, name or keyword.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 11
  • Comments: 35 (10 by maintainers)

Most upvoted comments

I wanted to chime in this has been occuring for me for a long time (not sure on the exact time frame) with Unity / VS Code. It occurs when I type “int” followed by spacebar and it completes to “iPhoneSettings”. I’m using Visual Studio Code on OSX. It is a major productivity drain for me.

Also, the Visual Studio Code issue @HardcodedNumber referenced is closed with the reason given that it’s an extension issue, not a VS Code issue.

Edit: I’d like to add that this is dependent on how quickly I type. If I type “int” and spacebar very quickly “iPhoneSettings” is inserted. If I pause before pressing the spacebar “int” is inserted.

Started happening to me following the recent update:

OS: macOS Mojave (10.14.5) VSCode version: 1.36.1 language within editor: Javascript

flaky_autocomplete

It seems like the autocompletion is selected by default and pressing the semicolon key triggers it.

EDIT: restarting vscode solved the issue.

And I’m afraid I can also reproduce with the latest Insiders build (1.29.0), with only the C# extension installed (at version 1.17.0).

Full version info
Version: 1.29.0-insider (user setup)
Commit: 9b2a7f4a83ca6a2d495463276a21157f398b41e7
Date: 2018-11-02T13:42:21.142Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64

This also happens to me many times daily. 50% of the time I type for example return new the new gets converted to nameof. From the comment here https://github.com/microsoft/vscode/issues/60753#issuecomment-430190566 it seems like the issue could be a missed “cancel” call on the async suggest handler? It appears what happens is:

  • I start typing “n”
  • The suggest system reacts to the “n” event but is slow to respond
  • A cancel on that request gets sent since I typed another char “e”, but it gets overlooked
  • I type “w” and that also gets overlooked
  • Now the suggest system responds with “nameof” since it sees that as the item to use: image
  • I type " " (space) and now the “nameof” gets selected/committed, since the suggest system never reacted to the cancel events.

Note this is just my analysis of what goes on, I have no real idea of how the code is structured.

Wrt repro, it appears this primarily happens with large repos. I think the way to test it would be to simulate slow responses by adding some Thread.Sleep(...).

Other cases where this appears:

  • Starting to type a lambda, the variable name gets replaced
  • The ones mentioned in the OP

This is a huge blocker for productivity since we constantly have to go back and fix the incorrectly committed suggestion.

I had to work on something else for a few days, so I didn’t have a chance to do any further testing on this until now. I have yet to experience the problem with the latest Insiders build, but that’s not really direct evidence of anything. The issue seemed to happen more frequently when I was focused and typing quickly, which is unfortunate since it would often disrupt that focus.

As far as extensions go, I have the following on both 1.26.1 and 1.27.0-insiders:

  • C# 1.15.2
  • Debugger for Unity 1.3.0