Repository navigation
fix(editor): open non-UTF-8 text files read-only in editors - #4022
Merged
Merged
Conversation
JammingBen
force-pushed
the
fix/editor-non-utf8-read-only
branch
from
October 26, 2026 12:06
70da816 to
d540166
Compare
JammingBen
marked this pull request as ready for review
October 26, 2026 12:25
kulmann
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Text editors (e.g. the text editor app) loaded file contents with
responseType: 'text'. The browser then replaced every byte that isn't valid UTF-8 (e.g. umlauts in a Latin-1 file) with U+FFFD, and the next save wrote those replacement characters back. That silently destroyed the original characters.Changes:
AppWrappernow loads text as raw bytes and decodes it with the newdecodeTextContenthelper. It detects UTF-16 by BOM and uses UTF-8 otherwise. If the bytes aren't valid UTF-8, it falls back to windows-1252 for display and reports the decoding as lossy.In collaborative (Yjs) sessions, a non-UTF-8 file is kept out of the shared room: the session runs locally, like it does for vault files. Every client opens such a file read-only, so there is nobody to collaborate with, and it can't be loaded into the room twice. A file that becomes non-UTF-8 through an external write while open is handled like any other external update (rare edge case, not worth the effort).