Saving a new file in a Rust project adds a `.r` extension
Check for existing issues
- [X] Completed
Describe the bug / provide steps to reproduce it
Saving a new file (cmd-n) causes the file name to have a .r extension. Zed does not recognize this as a rust file so no syntax highlighting is applied. After renaming the file to .rs, syntax higlhighting is applied.
Steps to reproduce:
- Open a Rust project in zed.
- Create a new file (
cmd-non Mac) - Save it as
test.rs - The file gets created as
test.rs.r
Environment
Zed: v0.147.2 (Zed)
OS: macOS 15.0.0
Memory: 24 GiB
Architecture: aarch64
If applicable, add mockups / screenshots to help explain present your vision of the feature
https://github.com/user-attachments/assets/3f55d60e-8a6f-4f27-a3ab-687db63fb906
Not reproducible on this env
Zed: v0.147.2 (Zed)
OS: macOS 14.5.0
Memory: 32 GiB
Architecture: aarch64
https://github.com/user-attachments/assets/e8dc256f-8d97-461f-8a51-ca2e1a9a2dc5
@uladkaminski Thanks for trying to reproduce.
Here is my screen recording.
https://github.com/user-attachments/assets/3f55d60e-8a6f-4f27-a3ab-687db63fb906
I can not reproduce this either. What happens if you save it as test.py for example?
Saving test.py saves as test.py and does not add a .r extension.
I wonder if it could somehow be related to
- #9765
@vbhavsar please, share the list of plugins you have installed.
Here are the extensions I have installed: HTML v0.1.2 TOML v0.1.1 Swift v0.3.0
I don't know how to find links for these extensions. Clicking on the github link takes me to the zed repo.
Tried to reproduce several times. No luck so far.
@uladkaminski Thank you!
I spent some time trying to see where .r gets added. I started out inspecting language and worktree crates. The path they see includes the .r extension so it must be upstream to those. I will check the fs crate next.
I also tried running git bisect but this issue surfaces even in commits from January 2024. I couldn't find a commit where this does NOT happen on my machine. Very strange.
A few more notes:
- I disabled all 3 extensions mentioned in https://github.com/zed-industries/zed/issues/16124#issuecomment-2291335653
- This issue happens in non-rust projects as well. Saving a
.rsfile in a python project exhibits the same strange behavior. - Creating a
.rsfile outside of zed does not add a.rextension.
After a lot more debugging, I have narrowed down the issue to ns_url_to_path. That code interacts with OS via cocoa so the issue might not be originating from zed code.
I have captured logs but they don't pinpoint the issue. Zed code only sees memory addresses which it converts to a string: https://github.com/zed-industries/zed/blob/28568429aa26260f273b86294b8f5d1bc5d95b7b/crates/gpui/src/platform/mac/platform.rs#L1335-L1337
might same #16969, as comments
Similar to #16969, I am also on macOS Sequoia Version 15.0 Beta. Although using tools outside of Zed (e.g. touch) does not cause the .r to be added.
Indeed, seems to be macOS-related bug so I'll close this as duplicate of https://github.com/zed-industries/zed/issues/16969