A small gripe, but one which gets me every time.
I use vscode with some auto-generated source files which are marked on disk as read-only. Because the auto-generated files appear similar to the normal source files in my project, I start to edit them and only discover when I try to save that I'm in the wrong file.
As well as #17621, it would be really useful to have a configurable editor option that prevents any editing of read-only files. Any keystrokes, pasting, etc are simply ignored.
Based on the source control I use and the way I use it, this is currently the biggest hurdle for me in migrating to VS Code.
From my experience, both Visual Studio and Notepad++ just respect file status on disk when it comes to editing. Sublime does not, but it's API supports a set_read_only function on views. VS Code currently does not seem to have either of these.
Ideally, VS Code would have a similar API support for plugins to be able to control view edit status, as well as a settings configurable ability to just respect on-disk file status. I'm personally more concerned with the API aspect, but I see them both as being useful.
The editor has an option readOnly that would need to be exercised by the workbench => removing editor label.
I'd love to see this too. I raised #31410 and based on the responsed implemented a text content provider however it caused a bunch of issues (for ex. Code didn't know that my new scheme was actually files, so paths to breakpoints etc. get messed up) and I've had to revert it. Now my users can edit package sources (equiv of node_modules) which is really not ideal.
I'd love to see this as well. We are using source control using locks. Being able to edit read only files causes only confusion.
Any updates/progress on this? I just ran into it and it's becoming an issue.
@alexandrudima Hi - is there any chance the fix you created in #37496 could be easily applied to this issue. Displaying your "Cannot edit" hint when trying to edit read-only source files would be great way to solve this.
@adelphes I think what's needed is for FileSystemProvider to be able to indicate readonly as part of what it returns from its stat method. I created #73122 to request this. Starting at 1.34 even access to the local filesystem is implemented as a FileSystemProvider, so its stat method would be able to check file permissions (and the readonly file attribute on Windows) and return the appropriate readonly value.
Could this feature also allow your workbench configuration to mark entire folders as read only?
We closed this issue because we don't plan to address it in the foreseeable future. You can find more detailed information about our decision-making process here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.
If you wonder what we are up to, please see our roadmap and issue reporting guidelines.
Thanks for your understanding and happy coding!
Most helpful comment
Based on the source control I use and the way I use it, this is currently the biggest hurdle for me in migrating to VS Code.
From my experience, both Visual Studio and Notepad++ just respect file status on disk when it comes to editing. Sublime does not, but it's API supports a set_read_only function on views. VS Code currently does not seem to have either of these.
Ideally, VS Code would have a similar API support for plugins to be able to control view edit status, as well as a settings configurable ability to just respect on-disk file status. I'm personally more concerned with the API aspect, but I see them both as being useful.