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

Quick fixes for the whole line are always shown #2878

Open
duncanp-sonar opened this issue Feb 22, 2022 · 0 comments
Open

Quick fixes for the whole line are always shown #2878

duncanp-sonar opened this issue Feb 22, 2022 · 0 comments

Comments

@duncanp-sonar
Copy link
Contributor

duncanp-sonar commented Feb 22, 2022

Description

The user is always shown quick fixes for all issues on the current line, rather than just for the "current" issue (i.e. the issue under the caret/the issue the mouse is hovering over).

This is confusing, particularly if there are multiple fixes with the same description as the user cannot tell which one will be applied.

Repro

  • open a file which in which a single line has multiple SonarLint issues with quick fixes on it.
  • put the caret in one of the issues on the line and wait for the list of suggested actions to appear
  • clicks on the in-line light-bulb / click on "show potential fixes"

Expected result

The resulting menu only shows fixes for the specific issue under the caret.

Actual result

The initial popup shows only the current issues:
image

However, the quick fixes menus shows fixes for all issues on the line:
image

Affected versions

SLVS v5.5+

Notes on the Roslyn implementation

The behaviour of the C# analysers is different: only fixes for the "current" issue are shown:

image

  • Quick fixes are calculated indeed with the span that VS gives (whole line)
  • They are calculating all the diagnostics within the span
  • The diagnostics are then grouped by their span
  • And they are calculating quick fixes for each diagnostic's span
  • The result of that is converted into action sets, so one action set for every diagnostic span
  • They are calculating the selection span from VS' span
  • All the sets are then ordered in correspondence to the selection span
  • The ordering uses a comparer that sorts the sets based on proximity -- if I understand this correctly, it will put the sets that are closest to the given selection span... ?
  • If there is no selection, then it puts the sets in whichever order
  • All the sets are then filtered by "title", which is each fix's message, picking distinct titles
  • So basically they're ordering and doing .First()
    What I (especially) don't understand is: why they are grouping based on diagnostic span? and not rule id for example? (edited)
@duncanp-sonar duncanp-sonar created this issue from a note in C++ Quick Fixes (In progress) Feb 22, 2022
@duncanp-sonar duncanp-sonar removed this from In progress in C++ Quick Fixes Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant