Skip to content
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

Feature request: Go to definition should be read-only when going outside workspace #17569

Closed
TethysSvensson opened this issue Jul 9, 2024 · 3 comments · Fixed by #17576
Closed
Labels
A-vscode vscode plugin issues C-feature Category: feature request

Comments

@TethysSvensson
Copy link

I often edit files in ~/.cargo/registry by accident, because I thought I was in a local copy of a crate.

Vscode has support for marking files as read-only (and other editors probably do as well). It would be nice mark files outside the current workspace as read-only by default, or otherwise introduce a small speedbump to prevent accidental editing of these files.

As a bonus extra feature, perhaps it should be possible to white-list certain paths outside the workspace, so they would also open in read-write mode.

@TethysSvensson TethysSvensson added the C-feature Category: feature request label Jul 9, 2024
@Veykril Veykril added the A-vscode vscode plugin issues label Jul 9, 2024
@Veykril
Copy link
Member

Veykril commented Jul 9, 2024

We can't really do much here, the language server protocol has nothing that allows us to tell the client that the file is readonly. And on the VSCode side readonly files are configured by a setting, I don't like rust-analyzer modifying the settings of a user too much, especially if we do it automatically.

We could offer a command maybe / put a button the landing page that adds the appropriate entry to the setting.

For context, the following config will make the standard libraries of all toolchains as well as all your crates-io libraries readonly

"files.readonlyInclude": {
    "**/.cargo/registry/src/**/*.rs": true,
    "**/lib/rustlib/src/rust/library/**/*.rs": true,
},

@TethysSvensson
Copy link
Author

I did not know those two settings existed. I agree that they prevent most accidental edits.

I think it would be a really nice service if rust-analyzer somehow made the users aware of this setting/helped them enable it, though I don't have an opinion on how to do this.

@bors bors closed this as completed in 13ac073 Jul 10, 2024
lnicola pushed a commit to lnicola/rust that referenced this issue Jul 11, 2024
internal: Remove faq landing page, improve main one

Having more than one is potentialyl annoying as both will get opened upon install, using walkthroughs for this is not ideal. So this merges the two and also adds a couple tips, fixes rust-lang/rust-analyzer#17569
@lnicola
Copy link
Member

lnicola commented Jul 15, 2024

I guess we could also show a notification here: "you're editing a file under ~/.cargo, you really don't want that".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-vscode vscode plugin issues C-feature Category: feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants