Skip to content

Add 'fileToRename' property to RenameInfo - #24702

Merged
4 commits merged into
masterfrom
fileToRename
Sep 10, 2018
Merged

4 commits merged into
masterfrom
fileToRename

Conversation

@ghost

Copy link
Copy Markdown

Fixes #24501

Adds a fileToRename property to RenameInfo so that the editor can rename the file instead.

@mjbvz Matt Bierner (mjbvz) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I'll get initial support for this in VSCode this month so people using typescript@next can start testing

Comment thread src/server/protocol.ts
* fileName to rename.
* If set, `getEditsForFileRename` should be called instead of `findRenameLocations`.
*/
fileToRename?: string;

@mhegazy Mohamed Hegazy (mhegazy) Jun 6, 2018 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be a folder as well.. e.g.

// modules/a/index.ts

export var a;
import * from "./modules/a";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should handle this case too.

And since we are renaming a module, we should also rename its references in tsconfig.json like "files"/"include"/"paths" etc..

I think we should just call in getEditsForFileRename instead of computing something on the fly.

@RyanCavanaugh

Ryan Cavanaugh (RyanCavanaugh) commented Sep 5, 2018 •

Copy link
Copy Markdown
Member

Andy (Andrewkraft) (@Andy-MS) please address conflicts + Mohamed's comments

@ghost

Copy link
Copy Markdown
Author

Matt Bierner (@mjbvz) Good to merge?

@mjbvz

Copy link
Copy Markdown

Yes, we don't have support in VS Code for this yet but I'll add it this iteration

@ghost
ghost merged commit 24a5bdd into master Sep 10, 2018
@ghost
ghost deleted the fileToRename branch September 10, 2018 18:25
@mjbvz

Copy link
Copy Markdown

Andy (Andrewkraft) (@Andy-MS) So is the expected behavior that when triggering rename on an import path in a file, we actually trigger the rename in the vscode file explorer?

@ghost

Copy link
Copy Markdown
Author

You could do that, which I'm guessing is the simplest way. Another option is to do the rename inline as usual, and change the name of the file without opening the file explorer.

@mjbvz

Copy link
Copy Markdown

Ok, just so I make sure I understand what is supported:

  1. Can you only rename the file itself or can you trigger a rename on directory in the path, such as renaming dir in import {} from './dir/file'

  2. As part of the rename, should I ever be able to change the path, e.g. doing a rename from import {} from './file' to import {} from './sub/renamedFile'

@ghost

Copy link
Copy Markdown
Author
  1. We trigger the rename on the entire string span, not on some part enclosed by /. (That could be changed if you want.) But if the import specifier is "./foo" and it imports from "./foo/index.ts", we'll try to rename the directory.
  2. I think so.

@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 21, 2025
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants