fix(search): truncate excerpt in sanitizeHtml to prevent slow search#3199
Open
jancborchardt wants to merge 3 commits into
Open
fix(search): truncate excerpt in sanitizeHtml to prevent slow search#3199jancborchardt wants to merge 3 commits into
jancborchardt wants to merge 3 commits into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This comment was marked as outdated.
This comment was marked as outdated.
generateNoteExcerpt() always truncated to 200 chars via truncateString() on the markdown path, but the sanitizeHtml() path added in #3155 returned the full content untruncated. Any note whose content matches the broad HTML_PATTERN (which includes informal tags like <todo>, <action>, generics like List<String>, or Markdown email syntax) would have its full 35-41 kB stored as the excerpt. On every search keystroke, the adapter called textView.setText() and highlightText() with those large strings on the main thread for every visible item, blocking the UI for several seconds. Fix: strip remaining HTML tags and truncate to 200 chars in sanitizeHtml(), consistent with the markdown path. Search still operates on the full note content via SQL LIKE. Fixes: #3180 AI-assisted: Claude Code (Sonnet 4.6) Signed-off-by: Jan C. Borchardt <925062+jancborchardt@users.noreply.github.com>
Fixes Codacy complexity warnings about duplicate string literals. AI-assisted: Claude Code (Sonnet 4.6) Signed-off-by: Jan C. Borchardt <925062+jancborchardt@users.noreply.github.com>
Fixes Codacy documentation warning. AI-assisted: Claude Code (Sonnet 4.6) Signed-off-by: Jan C. Borchardt <925062+jancborchardt@users.noreply.github.com>
6501f55 to
95c079c
Compare
Contributor
|
APK file: https://github.com/nextcloud/notes-android/actions/runs/26316063945/artifacts/7171801123 |
jancborchardt
commented
May 22, 2026
Member
Author
jancborchardt
left a comment
There was a problem hiding this comment.
Tested and can confirm this fixes the search performance issue introduced by #3155 @alperozturk96
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.
Summary
sanitizeHtml()added in Improve note preview #3155 returned the full note content untruncated, while the markdown path always callstruncateString(result, 200)HTML_PATTERN(which includes informal tags like<todo>, generics likeList<String>, or Markdown email syntax like<user@host>) would have its full 35–41 kB stored as the excerpt in the databasetextView.setText()andhighlightText()with those large strings on the main thread for every visible item, blocking the UI for several seconds (reported in Search very slow since latest release #3180)sanitizeHtml(), consistent with the markdown path — SQL LIKE search still operates on the full note contentTest plan
<placeholder>syntax, email addresses, etc.)./gradlew :app:testFdroidDebugUnitTest --tests "it.niedermann.owncloud.notes.shared.util.NoteUtilTest"Fixes #3180
🤖 Generated with Claude Code