-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Add 'renameFile' command to services #23573
Conversation
//cc @mjbvz |
We also need to consider |
Ok, I think this flow makes sense and the api looks good. We may also need an api to check if any renames are necessary so we can avoid prompting the user in cases with loose files |
src/services/tsconfig.json
Outdated
@@ -63,6 +63,7 @@ | |||
"navigateTo.ts", | |||
"navigationBar.ts", | |||
"organizeImports.ts", | |||
"../services/renameFile.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsut renameFile.ts
src/services/services.ts
Outdated
@@ -1950,6 +1950,10 @@ namespace ts { | |||
return OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); | |||
} | |||
|
|||
function renameFile(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings): ReadonlyArray<FileTextChanges> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name makes me think there is will rename the file as well.. how about getEditsForFileRename
@sheetalkamat What's a good way to get access to the |
@andy-ms the soruceFile for the tsconfig.json is stored in |
FWIW: most IDEs I’ve used, asked me – before the file was actually moved: “Do you also want to update references?” |
Is this supposed to work for renaming folders as well? It doesn't seem to in VS Code 1.24 / TypeScript 2.9.1. |
Folder rename should be working in |
Filed #24904 to track folder renames. |
Here's how I think it would work:
This is a bit tricky on the tsserver side since we need to be able to figure out what unresolved imports could have resolved to. This meant I had to leave
moduleResolutionCache
around so we could look at the failed lookup locations for failed imports.Fully expecting to need a lot of revision on this. CC @mjbvz for protocol review.