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
Propose API for [onWill|onDid][Create|Delete|Rename] #83822
Conversation
fyi @bpasero for changes in the file service |
@jrieken some feedback:
|
Yeah, that's the whole point of this API, e.g before renaming |
Jus to clarify what happens today when you move a dirty file:
Somewhere in there is the I think in general, I would:
(which I guess is very hard to enforce because an extension could simply write to the file on disk) PS: I am also not sure what this means for custom editors that potentially also have dirty state that is not under the control of the workbench... |
Moving things to the text service is easy, it just means that those events aren't fire when using the fs-api. Unless, we wire some of the fs-call through the text file service... Not sure what that means but the textfile service likely doesn't care if non-textfile uris pass through it. For now, I will move the will-events to the text file service. Likely also adding did-events on the text file service so that both events always come in pairs |
Maybe if extensions must have API to call move/copy/delete these methods should be exposed on a text document and then use the text file service under the hood. This would make it clear that the operations are considering dirty states and possibly more UI state of the document to carry over. |
@bpasero another challenge is that some extension would like to get bulk events, e.g when move 3 files in the explorer these should be one event listing those 3 files, not three events. This is to prevent expensive computations that need to be done. Extensions could solve this with debouncing but that's more fragile esp since we really know what's happening. Thought? |
Yeah I think that would require us to expose bulk methods on the text file service, or just accept an array of resources for move/copy/delete. |
@bpasero now it is really confusing as it seems that delete from the explorer doesn't go through the text file service but hits the file service directly. Is that the design? It seems to use the text file service to revert things but doesn't seem to use it for delete, in fact bulk edit seems to be the only user of TextFileService#delete. |
I have the feeling that those event might be best living in the file service and that we tackle the move-and-dirty case pragmatic, e.g by saving before applying an edit from extensions |
@jrieken that is correct, the explorer is doing something custom as you can see starting from here:
It will show a dialog asking to revert any files with dirty state. I think that makes sense to have on that layer because the bulk edit for sure does not want to bring up a dialog like that when running. However, if we introduce the events on the level of
This will cause a weird flow of things:
Why can we not do the edits on the model and keep the editor dirty? |
Hm, maybe this could work:
I am not sure just relying on the event would be enough for the text file service to do everything it does today, but it is something to investigate. |
Hm, that's an interesting thought. I am back and forth to where those events should live. If we move them into the file service we won't missing anything but also nothing can go unnoticed, e.g creating a log-file or deleting a temp-folder. The text-file service seems like a good abstraction of "user initiated" actions and would offer a clear boundary between the low-level and high-level world. Plus, it knows how to handle dirty move etc... Undecided. And then custom editors are likely to have an impact on the text file service, e.g it might have to morph into a working copy service. Let's discuss Monday and in person |
This PR is for #43768. It adds a new
onWillRunOperation
-event toIFileService
, removes the corresponding experiment from the text file service and exposes corresponding events in the API.Open questions
Using(see Propose API for [onWill|onDid][Create|Delete|Rename] #83822 (comment) and further comments)vscode.workspace.fs.delete
etc will trigger this event which IMO is very correct (an extension might run this as part as a command) but needs documentation