-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Set editor readonly for files that are readonly on disk #17670
Comments
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 |
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 |
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 |
Could this feature also allow your workbench configuration to mark entire folders as read only? |
Wait, what? The editor should have an option to prevent accidental editing of read-only files. For people who are stuck in older version control systems, the current behavior leads to easy accidents, such as:
|
I disagree and feel that this issue is crucial. |
Yes. I think it's time to get this re-opened and into the queue. At the very least, a real live person from the core team should comment here, please. |
Duplicate of #4873 |
While working on #161715, I made a patch that propagates stat.mode to set FilePermission.Readonly so textEditorModel.isReadonly() can dynamically sync with FileSystem.Readonly) That patch explicitly addresses the issue of "files which are marked on disk as read-only" being non-editable. (which is technically different from #4783, which is about files that are disk-writeable, but intended to be non-editable) (although it relies on code from #161716 to set |
I disagree that this is the same as #4873 - reading through the comments makes it clear that there are two different scenarios. This issue is focused on the read-only state of files in the file system and automatically preventing editing of those files. |
Since this is reopened: It simply applies the 'readonly' bit returned in the file-stat method to set the Permissions.readOnly flag. I know you have concerns that other Editor/Models may also be interested in the readonly status; |
Fixing it now sounds good, yes. There is no need to wait for other, more exotic features that happen to be related. And I see a much higher value-to-effort ratio for fixing this one, too. This is something that is obvious and required; most other editors already do the right thing for read-only files. |
There's the PR (one-line + import) |
Ok... diskFileService.test.ts is failing. I see the problem: There are two places where vscode tests: That is: That is a fundamental problem... MainThreadFileSystem, EditSessionsFileSystemProvider & DebugMemoryFileSystemProvider have I can imagine ways to do further hacks to ReadonlyHelper to workaround this, Note: Discussion is here, but the PR is merged with #161716, |
Resolved as follows: Because As a result, the actual file-stat readonly-ness could never be used to signal non-editibility. To preserve the 'allow DiskFileSystem to bypass throwIfFileIsReadonly()' feature, That is: instead of removing the standard, righteous Readonly permission indicator for the DiskFSP feature, This fix is 4 lines: This provably gives that same results as before, since the place that relied on a null FilePermission now detects the |
This landed in our insiders behind a new setting |
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.
The text was updated successfully, but these errors were encountered: