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
I have updated the PR to pair QStringDecoder with a persistent QStringEncoder(QStringEncoder::Utf8).
Because chunk 1 subtracts the 2-byte BOM, it ends on an offset boundary (4194302 % 4 == 2) that can split a 4-byte UTF-16 surrogate pair across the 4MB chunk boundary. Stateless toUtf8() on chunk 1 would turn an unmatched high surrogate into replacement characters, whereas a persistent QStringEncoder buffers and carries the pending surrogate into the next chunk seamlessly.
Appreciate the help with this and identifying these potentially nasty issues :)
I pushed a small tweak to the code. It goes ahead and instantiates the encoder. I would foresee the overhead of creating the encoder even when not needed would be miniscule compared to the rest of the disk read, encoding, and processing by Scintilla.
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
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.
Problem
Cause
Commit a74152a added UTF-16 support. It also introduced an unconditional call to
decoder(input)insrc/ScintillaNext.cpp.When the file is not UTF-16,
decoderis not initialized. Invoking an uninitializedQStringDecoderon Qt 6 dereferences a null pointer.Additionally,
decoderwas declared inside the chunk loop. On files larger than 4MB,decoderwas re-instantiated on every chunk.Solution
decoder(input)outside the UTF-16 conditional block.QStringDecoder decoderbefore the chunk loop to maintain decoder state across chunks.Fixes #1142
Note
This change is applied by the AI Gemini 3.8 Flash of Antigravity-CLI harness and the responsibility is for the author (Amirkia RAFIEI OSKOOEI).