zed icon indicating copy to clipboard operation
zed copied to clipboard

Saving a new file in a Rust project adds a `.r` extension

Open vbhavsar opened this issue 1 year ago • 11 comments

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:

  1. Open a Rust project in zed.
  2. Create a new file (cmd-n on Mac)
  3. Save it as test.rs
  4. 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

vbhavsar avatar Aug 12 '24 18:08 vbhavsar

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 avatar Aug 12 '24 21:08 uladkaminski

@uladkaminski Thanks for trying to reproduce.

Here is my screen recording.

https://github.com/user-attachments/assets/3f55d60e-8a6f-4f27-a3ab-687db63fb906

vbhavsar avatar Aug 12 '24 23:08 vbhavsar

I can not reproduce this either. What happens if you save it as test.py for example?

kud1ing avatar Aug 13 '24 12:08 kud1ing

Saving test.py saves as test.py and does not add a .r extension.

vbhavsar avatar Aug 13 '24 14:08 vbhavsar

I wonder if it could somehow be related to

  • #9765

Moshyfawn avatar Aug 15 '24 13:08 Moshyfawn

@vbhavsar please, share the list of plugins you have installed.

uladkaminski avatar Aug 15 '24 13:08 uladkaminski

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.

vbhavsar avatar Aug 15 '24 14:08 vbhavsar

Tried to reproduce several times. No luck so far.

uladkaminski avatar Aug 19 '24 15:08 uladkaminski

@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.

vbhavsar avatar Aug 19 '24 15:08 vbhavsar

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 .rs file in a python project exhibits the same strange behavior.
  • Creating a .rs file outside of zed does not add a .r extension.

vbhavsar avatar Aug 19 '24 15:08 vbhavsar

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

vbhavsar avatar Aug 21 '24 08:08 vbhavsar

might same #16969, as comments

CharlesChen0823 avatar Aug 31 '24 01:08 CharlesChen0823

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.

vbhavsar avatar Sep 01 '24 17:09 vbhavsar

Indeed, seems to be macOS-related bug so I'll close this as duplicate of https://github.com/zed-industries/zed/issues/16969

SomeoneToIgnore avatar Sep 23 '24 15:09 SomeoneToIgnore