-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Use snippets for extract refactorings #50166
Copy link
Copy link
Open
Labels
Domain: LS: Refactoringse.g. extract to constant or function, rename symbole.g. extract to constant or function, rename symbolExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Metadata
Metadata
Assignees
Labels
Domain: LS: Refactoringse.g. extract to constant or function, rename symbole.g. extract to constant or function, rename symbolExperience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsHelp WantedYou can do thisYou can do thisSuggestionAn idea for TypeScriptAn idea for TypeScript
Feature request
🔎 Search Terms
Problem
Today our extract refactorings run in two stages:
newFunction)This has a few problems:
Proposal
VS Code now supports including snippets in the workspace edits that extensions provide on refactorings. My proposal is that TS Server uses snippet syntax in the edit returned for extract method/constant so that users immediately start renaming the new function/constant instead of using the two phase flow we have to day
Example
For the TS:
If I select
1 + 2and select theextract to function in global scoperefactoring, I should get the following snippet (note that I'm using VS Code's snippet annotation here):Typing would update both places where newFunction is used: