Repository navigation
engine: keep case-insensitive replace from dropping text when folding shifts byte boundaries - #1364
Merged
aiongg merged 1 commit intoOct 22, 2026
Conversation
… shifts byte boundaries
jesusthehelper-oss
added a commit
to jesusthehelper-oss/gridcraft
that referenced
this pull request
Oct 19, 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.
Case-insensitive Find & Replace can silently truncate a cell whose text folds to the same total byte length but with shifted character boundaries:
replace_cisliced the original text at byte offsets found in the lowercased copy, and a fold such as U+212A KELVIN SIGN (3→1 bytes) or U+0130 (2→3 bytes) moves those offsets off character boundaries, sotext.get(..)returnedNoneandunwrap_or("")dropped the tail (with an empty replacement,input_to_cell("")deletes the cell outright).The fix adds
folds_in_place, which allows the slice-based fast path only when every character folds to exactly one character of the same UTF-8 length; foldings that can move boundaries fall back to the existing losslesstext.replace, and ordinary folds such asÉ→ékeep the fast path. The regression test entersKİİ(U+212A U+0130 U+0130) in A1, runsedit.replacewithwhat: "k", and asserts the cell text is unchanged — it fails on the old code (Text("x")vsText("Kİİ")) and passes with the fix;cargo test -p gridcraft-engine cmd::edit::testsstays green (8/8).Note for reviewers: open PR #980 reworks Find & Replace on character indices and would subsume this fix; if that lands first this branch can be closed. Until then this is the minimal data-loss fix that applies cleanly to current
main.Partially addresses #1307 (finding 5, case-insensitive replace corruption). Targeted tests green locally;
cargo xtask cileft to the project runners.