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

TypeScript Rename File Refactoring #19439

Closed
maxime1992 opened this issue Jan 26, 2017 · 16 comments
Closed

TypeScript Rename File Refactoring #19439

maxime1992 opened this issue Jan 26, 2017 · 16 comments
Assignees
Labels
feature-request Request for new features or functionality file-explorer Explorer widget issues on-testplan typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Milestone

Comments

@maxime1992
Copy link

When moving a file (drag'n drop), we then have to manually change every path where we used that file.

It would be nice to update all the import where we used that file.

@mousetraps mousetraps added feature-request Request for new features or functionality typescript Typescript support issues file-explorer Explorer widget issues labels Jan 27, 2017
@mousetraps
Copy link
Contributor

Cool idea!

cc @bpasero @dbaeumer @mjbvz

@dbaeumer
Copy link
Member

@waderyan this would best require some support from TypeScript to find all places where the file to be moved is referenced.

@mjbvz mjbvz added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label Apr 11, 2017
@mjbvz
Copy link
Collaborator

mjbvz commented Apr 11, 2017

The change file location refactoring required to implement this is tracked by microsoft/TypeScript#6487

@mjbvz mjbvz changed the title Move a file : Change import path where this file's used TypeScript Rename File Refactoring May 13, 2017
@waderyan waderyan removed their assignment Jul 13, 2017
@adenflorian
Copy link
Contributor

I believe webstorm has this functionality already, which would mean this is possible without needing changes to typescript? Unless this issue is specifically for refactoring typescript and not ES6 javascript?

@okonon
Copy link

okonon commented Nov 20, 2017

this would be nice!

@adenflorian
Copy link
Contributor

Is this issue only about TypeScript? If something was implemented upstream for this, would it also benefit JavaScript files? And what about all other file types? What if we used an implementation that would work for all files?

Anytime a file is renamed/moved, search all files in workplace for references to that file, and update the references. For each folder in the workspace, we calculate what a relative path to the renamed file would look like. Then search all files in that folder for a string that matches that relative path, and update any that were found. Or something along those lines...

@kyasbal
Copy link

kyasbal commented Nov 30, 2017

@adenflorian I also think this is not limited to Typescript.
Language server protocol have rename request in specification (https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#rename-request)
But that is just used for notifying renaming from editor. I guess we need some specification in language server protocol to fetch what will be occur after renaming the file.
Such a specification seems in discussion at this issue(microsoft/language-server-protocol#272).

@listepo-alterpost
Copy link

Hi, any news?

@sqrter
Copy link

sqrter commented Feb 5, 2018

Need this feature too

@alexgorbatchev
Copy link

I think this would be exceptionally useful!

@codyfyi
Copy link

codyfyi commented Apr 27, 2018

Coming to VS Code from WebStorm this is the only feature I found myself seriously missing!

Not just for TypeScript, but for ES6 and every other language. I'm not sure how JetBrains implements it, but I wonder if it would be possible to recognize path strings in the code and when a file within the project is moved or renamed, all path strings affected by the change could be updated.

Edit: I missed @adenflorian comment above somehow. +1

@webberwang
Copy link

webberwang commented May 7, 2018

How can people code without this feature?! This is the only reason stopping me from switching over to VSCode from WebStorm.

@nilshartmann
Copy link

Hello @webberwang,

while I also miss this feature a lot, this extension helps (even it's not as comfortable as Webstorm): https://marketplace.visualstudio.com/items?itemName=stringham.move-ts

(tbh for larger refactorings I still temporarily switch back to Webstorm)

@webberwang
Copy link

@nilshartmann thanks for the suggestion, I'll check out that extension

@chialunwu
Copy link

chialunwu commented May 11, 2018

Seems implemented and just merged in Typescript - microsoft/TypeScript#23726
Looking forward to the integration to vscode!!

@mjbvz
Copy link
Collaborator

mjbvz commented May 21, 2018

Fixed by #50074

However the feature only works if you are using the latest typescript@next build (the current typescript 2.9 version bundled in VS Code insiders is missing a few required fixes). We'll pick up a new typescript build with the fix sometime this week and it will also be included with VS Code 1.24

The initial version also only support single file moves/renames. Extending this to whole directory moves/renames is tracked by #50244

@mjbvz mjbvz closed this as completed May 21, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jul 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality file-explorer Explorer widget issues on-testplan typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests