[Issue] Code suggestions menu closes after SonarQube code analysis

Please provide

  • Operating system: Windows 11 Enterprise
  • Visual Studio version: 18.8.2
  • SonarQube for Visual Studio plugin version: 10.6.0
  • Programming language you’re coding in: C#
  • Is connected mode used: Yes, SonarQube Server Community Build v26.6.0

When editing code in Visual Studio, I often press Ctrl+. just as I am finished typing to quickly open the code suggestions menu. However, if I do this too fast the menu automatically closes about half a second later. I can reopen the menu just fine, and if I wait a second before opening the suggestions menu there is no issue.

The timing of the menu closing exactly coincides with:

  • The status text “SonarQube for Visual Studio: Analyzing 1 file” disappears
  • The “[Analysis] found X issues” printout in the SonarQube output window

I have tried disabling the SonarQube extension, and this resolves the issue. After re-enabling the extension, the issue reappears. This has been present in all recent versions of the extension/VisualStudio, for at least 6 months.

From a productivity standpoint this is very annoying, since it breaks my flow of concentration whenever I want to apply a code suggestion.

As an additional note, I am not currently using Github Copilot or some other AI productivity tool.

Hi. Can you try this build? SLVS-3027 Report only the changed span from issue/location taggers · SonarSource/sonarlint-visualstudio@bcfbcce · GitHub

Hi, thank you for the reply!

I tested the attached build a bit, and it does work better. The suggestions menu no longer closes at the end of every code analysis iteration.

It does still sometimes close unexpectedly. This seems to correspond to cases where a new issue has been found (i.e. the issue was not reported in the previous analysis iteration). It’s still annoying since the new issue usually isn’t related to the line I’m currently editing, but at least it’s somewhat less prevalent.

The editing scenario where I am most frequently bothered by this issue is:

  1. I add a new constructor parameter to a class
  2. I want to use the “Create and assign field” quick action to capture the constructor parameter in a field
  3. The suggestions menu closes before I can invoke the action

As I said it’s not perfect but it’s an improvement.

Does editing the ctor produce a Sonar issue on that line, like unused parameter or too many parameters?

New build will be here once the pipeline passes: SLVS-3027 Report only the changed span from issue/location taggers · SonarSource/sonarlint-visualstudio@d8723f0 · GitHub

Hi,

After testing for a while with the second build it seems like it works about the same as the first build. The suggestions menu closes when analysis finishes and new SonarQube issues have been found.

Does editing the ctor produce a Sonar issue on that line, like unused parameter or too many parameters?

Here is a discrepancy worth mentioning. The suggestions menu only closes when a SonarQube issue is produced, not when a standard Visual Studio issue is produced.

For example:

  1. Add a parameter within the allowed limit of parameters
  2. CS9113: Parameter 'xxx' is unread.
  3. Suggestions menu is not closed

Vs.

  1. Add one parameter too many
  2. csharpsquid:S107: Constructor has too many parameters
  3. Suggestions menu is closed

Hi. Previously, the implementation we had would always close the suggestions menu if any update happened to the issues in the file. The PR I created changed it to only close the suggestions menu if an issue happens to be at the same location as your caret. This was done as a trade-off, because I couldn’t figure out how to refresh the suggestions menu with our actions (added or removed, depending on what happened to the issue). I guess the too many parameters rule is a tricky one, because it raises an issue at your current caret location. I will see if I can somehow fix it, but it looks a bit complicated.

For me personally I don’t mind if the “suggestions” menu doesn’t close/update at all when the SonarQube analysis completes. The reason I open the menu right after I finish typing is always to access the standard refactoring actions. If a SonarQube suggestion is generated and I want to see the actions for that suggestion, I can always manually close and reopen the menu.

Hi, a new build is available here SLVS-3032 Fix lightbulb menu dismissal behavior · SonarSource/sonarlint-visualstudio@57220d0 · GitHub

Hi, after working on this build for a few days everything seems to work as expected!