feat(editor): add Find and Replace and Use Selection for Find to the Edit menu - #2893
Merged
Merged
Conversation
…tor and rename its modules
…e is toolchain-independent
…to feat/editor-find-and-replace
…package # Conflicts: # CLAUDE.md # LocalPackages/CodeEditTextView/Sources/CodeEditTextView/CodeEditTextView.swift # Packages/TableProEditor/Sources/TableProEditorKit/Controller/TextViewController+TextViewDelegate.swift # Packages/TableProEditor/Sources/TableProEditorKit/Controller/TextViewController+ToggleComment.swift # Packages/TableProEditor/Sources/TableProEditorKit/Extensions/NSRange+/NSRange+InputEdit.swift # Packages/TableProEditor/Sources/TableProEditorKit/Extensions/TextView+/TextView+Point.swift # Packages/TableProEditor/Sources/TableProEditorKit/Extensions/TextView+/TextView+TextFormation.swift # Packages/TableProEditor/Sources/TableProEditorKit/Extensions/TextView+/TextView+createReadBlock.swift # Packages/TableProEditor/Sources/TableProEditorKit/Filters/DeleteWhitespaceFilter.swift # Packages/TableProEditor/Sources/TableProEditorKit/Find/PanelView/FindPanelView.swift # Packages/TableProEditor/Sources/TableProEditorKit/Find/ViewModel/FindPanelViewModel+Replace.swift # Packages/TableProEditor/Sources/TableProEditorKit/Find/ViewModel/FindPanelViewModel.swift # Packages/TableProEditor/Sources/TableProEditorKit/SourceEditor/SourceEditor+Coordinator.swift # Packages/TableProEditor/Sources/TableProEditorKit/TextViewCoordinator/CombineCoordinator.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/CaptureModifierSetTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/CodeEditSourceEditorTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/Controller/TextViewController+IndentTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/Controller/TextViewController+MoveLinesTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/Controller/TextViewControllerTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/FindPanelTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/GutterNumberOffsetTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/Highlighting/StyledRangeContainerTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/Highlighting/VisibleRangeProviderTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldAccessibilityTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldChunkBoundaryTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldCollapsePathTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldDocumentSwapTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldHoverTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldPlaceholderClickTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldRibbonLookupTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldStorageTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/LineFoldingTests/LineFoldingModelTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/RangeStoreTests.swift # Packages/TableProEditor/Tests/TableProEditorKitTests/TreeSitterClientTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/AccessibilityTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/CmdUpAtEndOfDocumentTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/IMEInputTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/KillRingTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/LayoutManager/OverridingLayoutManagerRenderingTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/LayoutManager/TextLayoutManagerAttachmentsTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/LayoutManager/TextLayoutManagerTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/LineEndingTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/MarkedTextTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/NSBezierPathSmoothPathTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/NSTextInputRangeGuardTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/TextLayoutLineStorageTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/TextLineDisplayRangeTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/TextSelectionManagerTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/TextViewTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/TypesetterTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/VisualLineEndOfDocumentTests.swift # Packages/TableProEditor/Tests/TableProTextEngineTests/WordSelectionTests.swift
…to feat/editor-find-and-replace
…replace # Conflicts: # Packages/TableProEditor/Sources/TableProEditorKit/Controller/TextViewController+FindPanelTarget.swift
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
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.
Stacked on #2886.
The editor has had a working Replace mode since it was vendored, reachable only from a popup
inside the find panel itself. There was no menu item, no key equivalent, and
showFindPanel()reset the panel to
.findon every open, so the replacement field went away and the replacementtext with it. This puts both of macOS's remaining Find commands where macOS puts them.
Edit > Find
The submenu now reads in Apple's order, on Apple's keys:
Cmd+FCmd+Option+FCmd+GCmd+Shift+GCmd+EBoth new items are nil-targeted like the other three, so a focused editor answers for itself
through the responder chain and a window with no focused editor falls through to
MainSplitViewController, which dims them. Neither falls back to the result grid's find bar: thegrid has no replacement field, and a selected cell is a value rather than a search term.
Cmd+Option+Fchanges handsThat combo is Apple's Find and Replace key and TablePro had it on Toggle Filters, which moves
to
Cmd+Shift+F(free, and next to Find). This is the one user-visible decision in the PR and itis easy to reverse; both are rebindable in Settings > Keyboard, and anyone who has already rebound
either keeps their mapping. The alternative was giving a documented text-editing shortcut a
non-standard key, which is the thing "native, no custom ways" rules out.
The conflict is real rather than theoretical: the find commands are
.globalcontext because theydispatch by focus, and
.globaloverlaps every other context, so AppKit would have blanked one ofthe two items with no warning.
Behaviour
showFindPanel(mode:)takes the mode as anargument instead of resetting;
Cmd+Fpasses none.caret movement, which is what macOS does.
Cmd+Gis what walks to the next match afterwards.It is disabled with an empty caret, which needs
NSMenuItemValidationonTextViewController,because AppKit stops validating at the target it resolved and never asks
MainSplitViewControllerfor a focused editor. The conformance is@retroactive, since the appowns neither
TextViewControllernorNSMenuItemValidation.It does not write the system find pasteboard. TablePro's panel is its own state rather than
NSTextFinder's, so writing a pasteboard nothing here reads back would be half a feature.Tests
FindAndReplaceEntryTests(package): opening with no mode keeps the last mode, opening inreplace mode gives the 54pt panel, naming a mode switches an already-open panel, and the
replacement text survives a close and reopen.
UseSelectionForFindTests(package): an empty caret offers nothing, the selection becomes theterm and finds both matches, the panel stays shut and the caret stays put, and an empty
selection leaves an existing term alone.
FindMenuItemsTests(app): the five items in order, both new ones nil-targeted on the rightkeys, and both commands
.globalin the.editorcategory.MainMenuBuilderTests.findAndFilterDefaultsHoldnow pins all five find keys plus the filterbar's new one.
swift test --package-path Packages/TableProEditor --force-resolved-versions: 333 + 110 cases,0 failures.
swiftlint lint --strict: 0 violations.verify.sh docs: PASS.FindPanelMode.displayNameis localized, andFind and Replace…,Find and ReplaceandUse Selection for Findare in the strings catalog with all five languages, matching how theneighbouring find strings are translated.
MainSplitViewController+MenuValidation.isEnabledwas two lines under the 160-line limit, so thefind cases moved to
isFindCommandEnabled, which is where they read better anyway.