-
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
Let users select the file name with running the 'Move to file' refactoring #51772
Comments
Maybe show this ability to name the file always? If I'm refactoring code out of another file I'll most likely want to rename it something different than the class/function/variable name. Maybe this could be put into a setting to always prompt for file name? |
I also think this makes sense from a consistency-perspective. When you extract a function inside a file, you're asked for a function-name - you don't have to accept a default name, and then apply the rename-refactoring. The same should apply to this. Support for this should ideally be present in tsserver so this behaviour can easily be replicated in other editors too. |
I suggest one more request, that for quick refactoring and consistency, we could use a flag like - nameStrategy: [common name strategy] - to quick move function to a new file. Also, i think for now, the new files are always located in the current folder aside as original file, could we set a different file path when using the filename open box? |
I'm with @sevenryze here... We prefer to use kebab-casing for our file names, so I'd like to have that as a setting when moving a function to a new file. |
We could also use formatting in a setting like we do with the window-title "window.title": "${dirty}${activeEditorMedium}${separator}${rootPath}" not sure exactly how we'd say stuff like "IFoo" => "foo.interface.ts" or something... would require some regex capture-style stuff with built-in functions like "table case", "camelCase", "dashify" or whatever. Would love to have the dialog prompt minimally though. Right now I have to rename the file every time |
Would be great if this could show an input with predefined options in both pascal case and kebab case for quick picking, but also allow manual changes. So for example, initiating a move of Possibly helpful: |
Upon digging further it seems the new file name comes from typescript itself which doesn't offer the possiblity of overriding the file name. An issue might need to be opened in the TS repo as well. |
Since it's been a while, I'd like to express my interest in having this feature. It would be a big help to me to kebab case new file names automatically. |
You might consider adding a comment/thumbs up to this issue in the TypeScript repo |
I'm currently refactoring a bunch of files in our project, and definitely having a prompt to chose the file name would be of great help. |
I'd love to be able to set te path to which the file will be saved, too. Couldn't find an issue open for that? |
Moving this to TS as it would require a new TSServer API to support this feature Also somewhat related to #29988 |
This feature behaves very oddly when you have multiple symbols selected. |
+1 |
I think now you can use refactor code: "Move to file" and from there select "Enter new file path...". |
The "Move to file" trick is not available on other language like python sadly |
microsoft/vscode#50486
Currently if the new file cannot be resolved, it would be
newFile.ts
. Later I would have to manually update the filename. And in the case whenupdateImportsOnFileMove.enabled
is set to falsey, I'll have to rename the references to the new files too.Would be better to show an input for filename when no reasonable guess for the new file name exists.
The text was updated successfully, but these errors were encountered: