Skip to content

Present native find results above dimmed text - #483

Merged
simonbs merged 13 commits into
mainfrom
codex/native-find-result-presentation
Nov 4, 2026
Merged

simonbs merged 13 commits into
mainfrom
codex/native-find-result-presentation

Conversation

@simonbs

@simonbs simonbs commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

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 UIFindSession can turn it on and off with isFindResultPresentationActive.

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:

  • finding 1,000 matches: 1.08 ms
  • applying and presenting 1,000 matches: 34.98 ms
  • cycling through 100 matches: 247.09 ms total, or about 2.47 ms per change
  • scrolling for 180 frames: 2.82 ms average work and 3.66 ms p95
  • frame delivery: 16.67 ms average, with no intervals above 25 ms or 50 ms

Verification

  • all 435 Runestone tests pass on the iOS simulator
  • all 13 focused RunestoneEditor native Find tests pass against this branch
  • the 1,000-match benchmark passes in Release on the physical iPhone
  • focused presentation, 500-result caching, and find-interaction tests pass
  • the changed files pass SwiftLint

@simonbs
simonbs merged commit 7833092 into main Nov 4, 2026
8 checks passed
@simonbs
simonbs deleted the codex/native-find-result-presentation branch November 4, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant