microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.52k stars 29.39k forks source link

Show which diagnostics have quick-fixes in the problems view without needing to mouse over each #135366

Open DanTup opened 3 years ago

DanTup commented 3 years ago

When I hover over an item in the Problems list that has a fix, the icon changes to a lightbulb:

Screenshot 2021-10-19 at 09 45 09 Screenshot 2021-10-19 at 09 45 15

It would be nice if I could easily see which ones have quick-fixes so I can quickly work through them fixing them, skipping over those that don't (rather than waiting some amount of time to guess whether that background async request for fixes has completed or not).

I think this could be done by allowing extensions to provide a flag on Diagnostic saying whether the diagnostic has fixes or not (this should be optional and the async request still sent if it's not define, for backwards-compatibility and languages where it's expensive to compute this up-front).

mjbvz commented 3 years ago

@sandy081 This sounds like a feature request / UX feedback for the problems view itself. The JS/TS extension can provide these quick fixes eagerly if the problems view requests them

sandy081 commented 3 years ago

@mjbvz I thought this needs to introduce new tag or something. Is there a Diagnostic tag that exists already to know if a diagnostic has quick fixes or not?

DanTup commented 3 years ago

Is there a Diagnostic tag that exists already to know if a diagnostic has quick fixes or not?

The only tags currently documented for diagnostics are Deprecated and Unnecessary. Could a new tag be added to support this? (I'm interested in improving this for my Dart extension, so I'm as interested in the mechanism as much as having TS support :-))

mjbvz commented 3 years ago

@sandy081 For TypeScript at least, the quick fixes are lazily computed. We don't currently know if a diagnostic is fixable or not until we make another call to the typescript server. This means we cannot easily add a diagnostic tag

sandy081 commented 3 years ago

@DanTup does the Dart extension knows if a diagnostic can be fixable or not while the diagnostic is created?

DanTup commented 3 years ago

@sandy081 generally, yep. We have a flag that if set means there definitely are fixes, but if the flag is not set, then it's unknown and does not mean there are definitely not fixes (eg. it could create false negatives but not false positives).

If this was added as a tag, that seems like it would work well (eg. the tag means there definitely are fixes, and the absence of the tag does not mean there are not, they should still be lazily fetched).