Skip to content
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

Custom Text Editor dirty flag inconsistencies #998

Open
starakaj opened this issue Apr 5, 2024 · 0 comments
Open

Custom Text Editor dirty flag inconsistencies #998

starakaj opened this issue Apr 5, 2024 · 0 comments
Assignees

Comments

@starakaj
Copy link

starakaj commented Apr 5, 2024

Extension sample

custom-editor-sample

VS Code version

Version: 1.87.2 (Universal) Commit: 863d2581ecda6849923a2118d93a088b0745d9d6

What went wrong?

I'm trying to implement a custom text editor webview, based on the cat scratch example. Running the example, if you...

  1. Run the custom extension
  2. Create a new .cscratch document
  3. Add a new scratch
  4. Close the extension window without saving (I guess simulating a crash)
  5. Re-run the editor
  6. The document will appear to be "dirty" in the UI. However, saving will not clear the dirty flag, and any changes that happened between saving and the "crash" seem to be lost.

I tried setting a breakpoint inside the resolveCustomTextEditor function, and interestingly the document isDirty property is false here. So it makes sense somehow that saving wouldn't clear the dirty flag, since the underlying document probably just ignores the command. However, it looks like the UI still knows there are some changes in some buffer somewhere that aren't being saved.

One last data point that might be useful, the issue doesn't seem to be related to using getState and setState—if you get rid of these entirely, and rely completely on the underlying text document as the single source of truth with respect to state, the issue persists.

Here's a gif that shows saving not clearing the dirty flag.
cat-scratch-fever

@mjbvz mjbvz self-assigned this Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants