You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Numerous lints come with an auto-fix option, but we have to apply the fixes almost one by one, which is tedious.
Describe the solution you'd like
Since VS code already keeps tracks of the list of issues and offers to fix them, VS code could expose a command for "apply all fixes".
Similarly, we could have an option to, right before executing dartfmt, apply fixes for the file.
Fix all actions automatically fix errors that have a clear fix that do not require user input. They should not suppress errors or perform unsafe fixes such as generating new types or classes.
It should be implemented in the server so it's a single request that builds all fixes, and not enumerated on the client as applying fixes for one diagnostic could interfere with others (for example changing offsets, or invalidating some other fixes), and repeated round trips to the server could be slow.
I think the server already has all the parts necessary for this (between dart fix and the (experimental) edit.bulkFixes call in the original protocol), but I'm not certain if they're stable enough to expose here yet.
dart-lang/sdk@85d455f adds an implementation for "source.fixAll" which can be run from the command palette (Fix All) or added to editor.codeActionsOnSave.
It only fixes the same things that dart fix/flutter fix will fix (which is not the whole set of fixes available in the lightbulb menu, but those that are deemed safe to fix in an automated way (this work might not be complete, so it may still expand over time)).
Reacted by Far Se, M. Ali Bayram, Albert Mañosa and Nikki Goel
Activity
DanTup commentedon Jul 1, 2021
I think this would make sense implemented as a Source CodeAction (
source.fixAll), which can be added toeditor.codeActionsOnSave:https://code.visualstudio.com/updates/v1_32#_fix-all-source-actions
It should follow the guides given by VS Code:
It should be implemented in the server so it's a single request that builds all fixes, and not enumerated on the client as applying fixes for one diagnostic could interfere with others (for example changing offsets, or invalidating some other fixes), and repeated round trips to the server could be slow.
I think the server already has all the parts necessary for this (between
dart fixand the (experimental)edit.bulkFixescall in the original protocol), but I'm not certain if they're stable enough to expose here yet.DanTup commentedon Jul 7, 2021
dart-lang/sdk@85d455f adds an implementation for "source.fixAll" which can be run from the command palette (Fix All) or added to
editor.codeActionsOnSave.It only fixes the same things that
dart fix/flutter fixwill fix (which is not the whole set of fixes available in the lightbulb menu, but those that are deemed safe to fix in an automated way (this work might not be complete, so it may still expand over time)).ViniciusSossela commentedon Aug 3, 2021
@DanTup @rrousselGit I am trying to launch the
Fix Allcommand, but it doesn't show on the command palette. Am I missing something?DanTup commentedon Aug 3, 2021
See my reply at #3469 (comment), thanks!