Skip to content

Find + Replace across editor surfaces#296

Merged
Shpigford merged 2 commits into
mainfrom
find-replace
Apr 29, 2026
Merged

Find + Replace across editor surfaces#296
Shpigford merged 2 commits into
mainfrom
find-replace

Conversation

@Shpigford

Copy link
Copy Markdown
Owner

Summary

  • Adds find + replace + Replace All to Clearly. The existing find bar gains a chevron-toggleable replace row, case-sensitive (Aa) and regex (.*) toggles, and Replace / Replace All buttons on Mac, iOS, and the live-preview editor; ClearlyCore gets a regex-capable TextMatcher and a new ReplaceEngine (literal + \$0\$9 capture-group templates).
  • iOS gains its first UndoManager-backed programmatic-edit path so Replace / Replace All produce a single undoable step that restores both text and syntax-highlight state.
  • Documents four session learnings in CLAUDE.md: @Published willSet timing for Combine sinks, the SwiftUI .keyboardShortcut ⌥⌘-letter dispatch bug (with the existing NSMenuItem injection workaround), the iOS find-highlight removeAttribute(.backgroundColor) wipe requirement, and the worktree-local -derivedDataPath rule.

Fixes #250

Test plan

  • ⌘F shows the single-row find bar; chevron expands the replace row.
  • Type a query, click Replace → replaces current match and advances to the next at-or-after the replacement end; click Replace All → all replaced in one ⌘Z step; "Replaced N occurrences" inline label clears after ~2.5s.
  • Toggle Aa and .* after typing a query → matches re-compute live; invalid regex shows a red border.
  • iOS: same flows on the simulator with hardware keyboard; verify ⌘Z after Replace All restores text and highlights, and that successive keystrokes don't leave stale yellow fragments behind.
  • swift test --package-path Packages/ClearlyCore — 172/172 pass (9 existing TextMatcher + 7 new ReplaceEngine).

Expands the existing find bar with a chevron-toggleable replace row, case-sensitive and regex options, and Replace / Replace All on Mac, iOS, and the live-preview editor. ClearlyCore gains TextMatcher options + ReplaceEngine ($0–$9 capture-group templates). iOS gains its first UndoManager-backed programmatic-edit path so Replace All is one undoable step.

Fixes #250
Codifies four session learnings: @published willSet timing for Combine sinks, the silent SwiftUI .keyboardShortcut break for ⌥⌘-letter shortcuts (workaround via NSMenuItem), iOS find highlights needing an explicit removeAttribute(.backgroundColor) wipe, and always passing -derivedDataPath ./.build/DerivedData inside Conductor worktrees.
@Shpigford
Shpigford merged commit 3aa4431 into main Apr 29, 2026
4 checks passed
@Shpigford
Shpigford deleted the find-replace branch April 29, 2026 15:30
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.

Add find + replace/replace all

1 participant