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
Failed to save 'index.tsx': The content of the file is newer #5943
Comments
@bpasero maybe you can help with a better solution. What happens:
What I would like is when the file system provider is disposed, VS Code deletes all text models that used to "belong" to the file system provider. I haven't found a way to do this though. My quick fix is to use a different scheme each time I register the file system provider. |
I think that is dangerous and could result in data loss. I might have an extension installed that allows to make changes to an editor with a custom FSP and scheme and when I disable that extension, my changes are lost? We are very very restrictive when to dispose a text file model, we actually only allow it unless the changes have been discarded or saved. |
Maybe I do not fully understand why the file system provider is created and disposed when this happens. We do have a similar flow in core where we have a custom FSP only for resolving dirty writes (the conflict resolution to this error). |
@bpasero what if I fire a |
I only need the file system provider to be registered when in conflict resolution mode, that's why I create and dispose it when entering and leaving conflict resolution mode. |
There may be a bug here that we can fix, but to clarify: if an editor is dirty (has changes), we never go to the file system to resolve it but always resolve it from the editor model because the file will not have the changes and the content is in memory anyway. To remove these changes you would have to trigger the command to revert the editor. Otherwise, if not dirty: In order to prevent going to the file system if there are no changes, we actually have a logic in place to figure out if the file has changed on disk compared to the version we have in memory (this requires the text model to be still around and not disposed). This depends on Maybe thats whats happening here? Are you implementing See also the docs around this: |
Autosave was on. I also closed the editor and wasn't prompted about dirty files.
Pretty sure I have this correct. |
Yeah thats true, another optimisation is that opening a model that is in-memory (e.g. still opened as tab) does not wait for the file service call but would show as it is in-memory and then try to see if newer content is there. Otherwise opening an existing tab would block for the duration of disk IO. |
This optimization makes sense, but I think as an extension I expect that if the tab is closed and I have disposed my filesystem provider then the in-memory model would not be used. I've worked around this by having my file system provider register with a different scheme each time. |
@alexr00 yeah so another thing that likely hits you is that text models are kept in-memory even after closing the tab for I think 3 minutes. @jrieken would be able to tell more, I think we do this because there is no explicit lifecycle in extension API to dispose a text model that has been opened (but I maybe wrong). |
To verify:
|
I tried with this repo https://github.com/andreamah/test-repo and this branch andreamah/test-repo#1 |
Good find @andreamah! |
Testing #5939
Failed to save 'index.tsx': The content of the file is newer. Please compare your version with the file contents or overwrite the content of the file with your changes.
The text was updated successfully, but these errors were encountered: