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

Adopt code actions ranges for refactorings in TS #57264

Closed
justschen opened this issue Feb 1, 2024 · 4 comments · Fixed by #57608
Closed

Adopt code actions ranges for refactorings in TS #57264

justschen opened this issue Feb 1, 2024 · 4 comments · Fixed by #57608
Assignees
Labels
Committed The team has roadmapped this issue Fix Available A PR has been opened for this issue Suggestion An idea for TypeScript

Comments

@justschen
Copy link
Contributor

justschen commented Feb 1, 2024

see API proposal here: microsoft/vscode#199608

vs code tracking: microsoft/vscode#204040

The API was made since often times in refactorings such as with extract or move too... it's not always clear what part of code or what part of the file the actions will apply to. By allowing contributed Code Actions to provide one or more ranges (Range[]), the range will be highlighted to show the user what will be changed.

All we need to provide is a Range[] of affected code. For refactorings, this range would be the code in the current file that will be effected by the refactoring.

@ashu8912
Copy link
Member

ashu8912 commented Feb 2, 2024

Hey @justschen can I pick this one?? Would be a great start for me to learn and start my first contribution to the project.

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript In Discussion Not yet reached consensus Committed The team has roadmapped this issue and removed In Discussion Not yet reached consensus labels Feb 2, 2024
@RyanCavanaugh RyanCavanaugh added this to the TypeScript 5.5.0 milestone Feb 7, 2024
@justschen
Copy link
Contributor Author

@RyanCavanaugh @navya9singh heads up I've done some work on the vs code / extension side for quick fixes already microsoft/vscode#204191. If you have questions about API usage lmk 👍

@navya9singh
Copy link
Member

navya9singh commented Feb 21, 2024

@justschen thanks for the update! For refactorings, do you want the ApplicableRefactorInfo api to have another parameter for range?: Range[] in the protocol?
I looked through what Range looks like on the vscode side, and it seems that it has more information other than start and end. Is that something that is needed on the TS side as well?
@mjbvz

@justschen
Copy link
Contributor Author

@navya9singh for the purposes of the highlights, we use startLine, startCharacter, endLine, and endCharacter since we convert it to the vscode IRange type to be used in the editor. everything else won't be checked/used so likely won't have to implement those 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Committed The team has roadmapped this issue Fix Available A PR has been opened for this issue Suggestion An idea for TypeScript
Projects
None yet
5 participants