Repository navigation
Fix text editor search crash and stale highlighting after document edits - #4801
Open
jester-sys wants to merge 1 commit into
Open
jester-sys wants to merge 1 commit into
jester-sys wants to merge 1 commit into
Conversation
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
This PR fixes the text editor crash and incorrect search highlighting that occur when the document is modified while a search is active.
Fixes #4792.
Root Cause
Search result indices were not invalidated when the document content changed. As a result, the previous and next navigation buttons continued using outdated character offsets.
When the document was shortened, these invalid offsets were passed to
setSpan(), causing anIndexOutOfBoundsExceptionand loss of unsaved changes.Same-length text replacements could also result in incorrect highlighting.
Changes Made
Before Fix
The application crashes when navigating search results after shortening the document.
Crash Log
Before Fix Video
🎥 Watch Video Demonstration
Before.Crash.Video-2.mp4
After Fix
🎥 Watch Video Demonstration
After_View-2.mp4
Logcat Verification
No recurrence of the reported
IndexOutOfBoundsExceptionor related fatal exception was observed in the post-fix log capture.[Attach after-fix crash log here]
After Fix Video
Manual Testing
Testing Environment
com.amaze.filemanager.debugScope
The changes are limited to
TextEditorActivity.java. Existing file-saving and document modification tracking logic remains unchanged.All listed manual regression tests passed.