Repository navigation
Present native find results above dimmed text - #483
Merged
Merged
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.
Why
When Find is open in apps like Notes, the document fades into the background while the matches stay bright. The current match also lifts off the page for a moment when you move to the next or previous result. It makes it immediately clear what you found and which occurrence you are looking at.
Runestone already draws the match colors, but because it is a custom text view, it does not get that extra presentation from UIKit for free. This change gives Runestone the same kind of visual treatment so apps using the native find navigator do not have to recreate it themselves.
Performance is central to Runestone, so this stays on the normal rendering path. It does not capture snapshots of the editor or rebuild match geometry while scrolling.
What changed
While a find session is active, Runestone places a subtle dimming layer over the editor and cuts out the matched ranges so they remain clear. The selected match is a slightly larger rounded plate behind the existing text, with its own soft shape shadow and a short spring animation when the selection changes. The animation is skipped when Reduce Motion is enabled.
The geometry for all matches is calculated once and cached in document coordinates. Scrolling moves the existing editor content and presentation together, without recreating text ranges, selection rectangles, views, or images. Moving between existing results reuses the same cached geometry.
Changing the selected result now updates highlight fragments only on the old and new selected lines. The other matches keep their existing highlight objects and cached fragments. This matters for documents with hundreds of matches, where rebuilding every result for each tap was the main cost.
Search highlights now carry enough information to distinguish an ordinary highlight, a found result, and the currently selected result. Runestone manages the presentation automatically for its built-in find interaction. Apps with a custom
UIFindSessioncan turn it on and off withisFindResultPresentationActive.Performance
The PR includes an opt-in 1,000-match benchmark covering matching, applying highlights, scrolling, and changing the selected result. In the same simulator benchmark, cycling through 100 matches dropped from 2.87 seconds to 0.79 seconds, a 73% reduction.
The final Release benchmark on an iPhone measured:
Verification