Allow FileSystemProvider to stat a file as readonly (#73122)#111237
Allow FileSystemProvider to stat a file as readonly (#73122)#111237bpasero merged 16 commits intomicrosoft:mainfrom
Conversation
The checks are in place and things are defined proposed.d.ts - so all good from that side. All API proposals are discussed during a weekly call and I can represent this issue. So far, the FS provider API has been posix-like and this isn't strictly like it anymore, tho personally I don't mind it. |
bpasero
left a comment
There was a problem hiding this comment.
Left some feedback in the code. On top of that:
- isn't
mainThreadFileSystem#$statmissing to set thereadonlyflag? - this should get a test to verify the text editor model reports readonly for readonly file stat
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
Outdated
Show resolved
Hide resolved
Added in latest push.
I'd appreciate some guidance on doing this. I have updated my branch of fsprovider-sample so the readonly state of a file can be toggled while open. If I close the file tab and reopen it the readonly state of the editor changes, but I think this needs to happen dynamically. @bpasero you recently did something similar in #110854 to handle a FSP's readonly capability changing on the fly. |
|
I am back at my desk after the holidays, so I've removed draft status from this PR. |
|
@gjsjohnmurray sorry for the time this took. I tried to bring your branch up to date with Remaining tasks:
[1]
[2] |
@bpasero I'm not familiar with this procedure. I have now set the PR's checkbox |
|
@gjsjohnmurray done |
|
@gjsjohnmurray are you planning to work on this further? Otherwise I can look into the finishing touches. From a API discussion we had today, we picked one of the proposals from #73122 (comment). Basically it would be this: export enum FileStatPermissions {
/**
* The file is readonly.
*/
Readonly = 1
}
/**
* The `FileStat`-type represents metadata about a file
*/
export interface FileStat {
/**
* The permissions of the file, e.g. whether the file is readonly.
*
* *Note:* This value might be a bitmask, e.g. `FileStatPermissions.Readonly | FileStatPermissions.Other`.
*/
permissions?: FileStatPermissions;
} |
|
@bpasero I'll happily leave it in your safe hands. Thanks! |
|
Thanks 🥂 |
This draft PR addresses #73122
It adds an optional
readonlyboolean property to the FileStat interface, thus enabling a FileSystemProvider to control whether a file is editable or read-only.One way to test:
Submitted as a draft PR seeking comment and guidance from @jrieken about taking this through the API proposal precedure.