This is a POC project to demonstrate the issue with file renaming in VS Code - namely 1) After a file has been renamed by a user, the VS Code APIs return the stale name, and 2) the sourceUri passed when invoked via the explorer is different from the sourceUri that's passed when invoked via a contextual menu in a document.
This is a boilerplate VS Code extension, with the following events added:
- example.tree.node.command
- example.editor.command
Both of these commands call exampleCommand()
in extension.ts
.
To reproduce the bug:
- Run VS Code with this extension
- Open a project
- In the explorer, right-click on a file and select
Rename
. - Rename the file's name. Only change the case of some of the characters, don't add or remove characters. (eg. rename
homepage.html
tohomePage.html
) - In the explorer, right-click the same file and select
Example Tree Node Command
Result:
When debugging, you should break into exampleCommand()
. Observe the sourceUri that's passed in, and notice that the paths in sourceUri are to homePage.html
, which is expected.
- If not already opened, open the file that was renamed (eg
homePage.html
) - Right-click within the editor and select
Example Editor Command
Result:
When debugging, you should break into exampleCommand()
. Observe the sourceUri that's passed in, and notice that the paths in sourceUri are incorrect, and are the stale/original homepage.html
.
There are two bugs here:
- After a file has been renamed by a user, the VS Code APIs return the stale name
- The sourceUri passed when invoked via the explorer is a different from the sourceUri that's passed when invoked via a contextual menu in a document.