You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unsaved text editor changes are lost or corrupted when the open file is renamed to another extension #4299
If a file open in the text editor is renamed to a different extension before its first save (e.g. notes.md -> notes.txt), the editor's unsaved changes are lost or corrupted.
The resources store holds the same object as the AppWrapper's resource until the first save. The rename therefore updates resource.extension in place. The text editor's Yjs adapter picks its content type from resource.extension on every call, while the mounted editor keeps the content type it was loaded with.
Reproduction Steps
Open notes.md in the text editor. Don't type and don't save.
Rename it to notes.txt via the sidebar or another tab.
Type something. The console shows [yjs] serialize for content update failed: ... Unknown node type.
Close the editor. There's no unsaved-changes prompt and the edits are gone.
Expected Outcome
The edits stay intact. At worst, saving fails with a conflict, so the user can copy the content or use "Save As".
Actual Outcome
md -> txt: serializing the markdown document as plain text throws ("Unknown node type"). The error is swallowed, the editor never becomes dirty, closing doesn't ask, and the edits are lost.
txt -> md: the content gets saved with markdown escaping (doubled newlines, \_, \#, 1\.).
After the first save the AppWrapper holds its own copy of the resource and the problem no longer occurs.
Activity