Skip to content

Proposal: 'Fix All In File' for CodeFixes #14549

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

Closed
mjbvz opened this issue Mar 9, 2017 · 8 comments · Fixed by #20338 or #21247
Closed

Proposal: 'Fix All In File' for CodeFixes #14549

mjbvz opened this issue Mar 9, 2017 · 8 comments · Fixed by #20338 or #21247
Labels
Committed The team has roadmapped this issue Fixed A PR has been merged for this issue Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Mar 9, 2017

From microsoft/vscode#22220

Problem
The current TypeScript code fixes must be applied individual. For fixes such as remove unused import, we would also like to support applying the fix to across all effected locations in a file.

Possible Approaches
To support this scenario across various editors and tools, the best approach would have the TSServer itself return Fix all in File type code fixes when getCodeFixes is requested. No TSServer API/protocol would have to be updated to support this. My only concern is that calculating the edits for fixing all problem in a file may be expensive and could bog down the TSServer.

The alternative would be to implement the fix all in file logic in VSCode. To do this, we would make multiple calls to getCodeFixes against the TSServer to build up a set of fix all in file code actions. Each type of CodeAction returned by TSServer would need a kind identifier so that we can bundle all instances of the same kind together. We would also need to know which types of code fixes can be applied across an entire file

@mhegazy and anyone else, please let me know if you have any thoughts on this

@mjbvz mjbvz added the VS Code Tracked There is a VS Code equivalent to this issue label Mar 9, 2017
@pcgeek86
Copy link

Just ran into this with the VSCode-PowerShell extension. If I select some code and try to Quick Fix All, there is no option to do so.

screen shot 2017-05-11 at 10 00 58 am

Cheers,
Trevor Sullivan

@mhegazy mhegazy self-assigned this May 11, 2017
@mhegazy mhegazy added the Suggestion An idea for TypeScript label May 11, 2017
@mhegazy mhegazy added this to the TypeScript 2.4 milestone May 11, 2017
@mhegazy mhegazy modified the milestones: TypeScript 2.4, TypeScript 2.5 Jun 5, 2017
@mhegazy mhegazy modified the milestone: TypeScript 2.6 Aug 31, 2017
@mhegazy mhegazy modified the milestones: TypeScript 2.6, TypeScript 2.7 Oct 9, 2017
@mhegazy mhegazy added the Committed The team has roadmapped this issue label Oct 19, 2017
@mhegazy mhegazy assigned ghost and unassigned mhegazy Oct 19, 2017
@DanielRosenwasser
Copy link
Member

Perhaps related to #19255.

@mjbvz
Copy link
Contributor Author

mjbvz commented Dec 13, 2017

Hey @Andy-MS, is this new API exposed in protocol.d.ts? I took a quick look in typescript@next but didn't see it

@ghost
Copy link

ghost commented Dec 13, 2017

@mjbvz Sorry, shouldn't have closed this. It's available at runtime but we haven't solidified the API. See #20538.

@ghost ghost reopened this Dec 13, 2017
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jan 4, 2018
@ghost
Copy link

ghost commented Jan 17, 2018

The API is now public (#21234).

@ghost ghost closed this as completed Jan 17, 2018
@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 17, 2018

Thanks @Andy-MS!

Question on testing: we should now see a fixId returned on some code actions returned from getCodeFixes, correct? I'm using a master TS build but am not seeing these. Any specific quick fixes / errors I should be using for testing?

@ghost
Copy link

ghost commented Jan 17, 2018

Try again with #21247

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 17, 2018

Ok, working now. Will try to get initial vs code support for this in today

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Committed The team has roadmapped this issue Fixed A PR has been merged for this issue Suggestion An idea for TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
4 participants