Is your feature request related to a problem? Please describe.
Saving over a read-only file used to behave differently per platform, because atomic_write replaces the file by renaming a temp file over it — and a rename is authorised by the directory's permissions, not the target's.
|
Before |
| macOS / Linux |
chmod 444 was ignored: the file was rewritten, and the read-only bit restored afterwards, so nothing showed the protection had been bypassed |
| Windows |
MoveFileExW refuses a read-only destination, so the save failed |
A separate PR makes all three platforms refuse, which stops the silent bypass and makes the behaviour consistent. The buffer stays dirty and a toast reports … is read-only, so nothing is lost.
Worth flagging: that removes a capability on macOS and Linux. Anyone who was editing a read-only file there and saving successfully now gets an error instead. It was arguably never correct — the app was overriding a protection the user set — but it is a user-visible change and you should be the one to decide it stands.
Describe the solution you'd like
VS Code prompts instead of failing: "Failed to save … the file is write protected" with Overwrite / Cancel, and Overwrite clears the bit, writes, and restores it. That is friendlier than a dead end, since the user usually knows exactly why the file is read-only.
Describe alternatives you've considered
- Keep the plain error (what the PR does). Nothing more to build, and the message names the cause.
- Prompt to overwrite. Needs a distinguishable error code from the backend, a confirmation in the frontend, and a
force path through the save command — a small but real UI contract, which is why it is not bundled into a fix PR.
- Show read-only state in the UI before the save is attempted, so the user is not surprised at save time. Could stand alone or accompany either option above.
Happy to implement whichever you prefer.
Is your feature request related to a problem? Please describe.
Saving over a read-only file used to behave differently per platform, because
atomic_writereplaces the file by renaming a temp file over it — and a rename is authorised by the directory's permissions, not the target's.chmod 444was ignored: the file was rewritten, and the read-only bit restored afterwards, so nothing showed the protection had been bypassedMoveFileExWrefuses a read-only destination, so the save failedA separate PR makes all three platforms refuse, which stops the silent bypass and makes the behaviour consistent. The buffer stays dirty and a toast reports
… is read-only, so nothing is lost.Worth flagging: that removes a capability on macOS and Linux. Anyone who was editing a read-only file there and saving successfully now gets an error instead. It was arguably never correct — the app was overriding a protection the user set — but it is a user-visible change and you should be the one to decide it stands.
Describe the solution you'd like
VS Code prompts instead of failing: "Failed to save … the file is write protected" with Overwrite / Cancel, and Overwrite clears the bit, writes, and restores it. That is friendlier than a dead end, since the user usually knows exactly why the file is read-only.
Describe alternatives you've considered
forcepath through the save command — a small but real UI contract, which is why it is not bundled into a fix PR.Happy to implement whichever you prefer.