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 fix all showing up even if there is only one error #21458

Closed
mjbvz opened this issue Jan 29, 2018 · 5 comments
Closed

Quick fix all showing up even if there is only one error #21458

mjbvz opened this issue Jan 29, 2018 · 5 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Jan 29, 2018

Code

class Foo {
    prop: number

    foo() { prop }
}

Using VS Code insiders, trigger quick fix on prop in foo

Expected behavior:
Only a single code action is shown

Actual behavior:
The base code action and a quick fix all code action are shown. The latter doesn't make sense as there is only a single error in the file

@andy-ms Is this something we are supposed to handle on the VS Code side or should getCombinedCodeFix be smarter here?

@RyanCavanaugh
Copy link
Member

Isn't this desirable? If you bound a key combination to Quick fix all, you wouldn't want it to not work when there was only 1 thing to do.

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 29, 2018

This is for our lightbulb context menu:

screen shot 2018-01-29 at 11 59 56 am

Having the extra entry doesn't make sense since there is only one error

@mhegazy
Copy link
Contributor

mhegazy commented Jan 31, 2018

This is something that should be handled on the IDE side. Ideally we do not want to require for all errors just to produce quick fixes (getting errors is expensive). A simple approximation here is if the diagnostic code has been reported only once in this file, then you can ignore the fixId, and not show the additional menu item.

@mhegazy mhegazy added the Working as Intended The behavior described is the intended behavior; this is not a bug label Jan 31, 2018
@mjbvz
Copy link
Contributor Author

mjbvz commented Feb 1, 2018

Ok, I can make this change for VS Code 1.20. Just to make sure I understand: it is safe to assume that any diagnostic that only appears once in a file will not have a "fix all" action?

@ghost
Copy link

ghost commented Feb 1, 2018

it is safe to assume that any diagnostic that only appears once in a file will not have a "fix all" action?

I think we will always provide a fix-all action, but the action would only end up fixing one thing (since there is only one diagnostic).
But there's also the problem that a diagnostic code may appear only once, but there may be other diagnostic codes that would be part of the same fix...

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

3 participants