Skip to content

fix(macOS): unify find/replace match scanning with highlight logic#249

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-inspection-2118
Draft

fix(macOS): unify find/replace match scanning with highlight logic#249
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-inspection-2118

Conversation

@cursor

@cursor cursor Bot commented May 17, 2026

Copy link
Copy Markdown

Summary

Find-in-note highlights were built by searching for query.lowercased() with .caseInsensitive, while Replace All and next-match navigation searched for the raw query with .caseInsensitive. Those two approaches can disagree under locale-sensitive Unicode case folding, so the yellow highlights could cover different substrings than Replace / Replace All would modify.

Changes

  • Add LinkAwareTextView.caseInsensitiveNonOverlappingMatchRanges(in:query:maxCount:) and use it for highlights (cap 2000), Replace All (no cap), and nextMatchIndex (cap 2000).
  • Add LinkAwareTextViewFindMatchRangesTests to lock in basic behavior.

Validation

  • Web: npm install and npx vitest run in web/ (257 tests passed). macOS XCTest was not executed in this Linux environment.
Open in Web View Automation 

Find highlights used query.lowercased() while Replace All and next-match
used the raw query, both with .caseInsensitive. That can diverge under
locale-sensitive folding so highlighted spans could disagree with what
Replace / Replace All actually edits. Route all three through one helper
and add unit tests for the range collector.

Co-authored-by: Danny Peck <dannypeck@gmail.com>
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