Find and Replace Refactor#311
Merged
austincondiff merged 6 commits intoCodeEditApp:feat/find-replacefrom Apr 22, 2025
Merged
Conversation
Collaborator
Author
|
That was odd but opening/closing it made the merge work so there's no conflicts now. @austincondiff when you have time to take a look I'd appreciate feedback on these changes. It's a lot but I'm pretty certain I maintained all existing functionality, including the changes already on the branch for case sensitivity. |
austincondiff
pushed a commit
that referenced
this pull request
Apr 29, 2025
### Description @austincondiff has been building out the 'replace' functionality and realized the way we had structured the panel, controller, target, and model was extremely overcomplicating things. This PR is an attempt to fix that Changes: - Moves all 'business logic' into the `FindPanelViewModel` observable object. This includes clarified methods like `find`, `replace`, and `moveToNextMatch/moveToPreviousMatch`. All state has been moved to this object as well, out of a combination of both the SwiftUI view and the find view controller. - Removes the `FindPanelDelegate` type entirely. All that type was doing was passing method calls from the find panel to it's controller. Since all that logic is now in the shared view model, the controller & view can just call the necessary methods on the model. - Simplifies the `FindViewController` to only handle view/model setup and layout. - Changes the focus state variable to an enum instead of two `Bool`s. This fixes an issue where there was a moment of nothing being focused when switching between the find and replace text fields. - Removes the unnecessary `NSHostingView -> NSView -> SwiftUI View` structure, replacing it with an `NSHostingView` subclass `FindPanelHostingView` that hosts a `FindPanelView`. - Clarifies some view naming to reflect what each type does. - `FindPanel` -> `FindPanelHostingView` - `FindPanelView` search fields moved to: - `FindSearchField` - `ReplaceSearchField` ### Related Issues * #295 ### Checklist <!--- Add things that are not yet implemented above --> - [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md) - [x] The issues this PR addresses are related to each other - [x] My changes generate no new warnings - [x] My code builds and runs on my machine - [x] My changes are all related to the related issue above - [x] I documented my code ### Screenshots <!--- REQUIRED: if issue is UI related --> <!--- IMPORTANT: Fill out all required fields. Otherwise we might close this PR temporarily -->
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.
Description
@austincondiff has been building out the 'replace' functionality and realized the way we had structured the panel, controller, target, and model was extremely overcomplicating things. This PR is an attempt to fix that
Changes:
FindPanelViewModelobservable object. This includes clarified methods likefind,replace, andmoveToNextMatch/moveToPreviousMatch. All state has been moved to this object as well, out of a combination of both the SwiftUI view and the find view controller.FindPanelDelegatetype entirely. All that type was doing was passing method calls from the find panel to it's controller. Since all that logic is now in the shared view model, the controller & view can just call the necessary methods on the model.FindViewControllerto only handle view/model setup and layout.Bools. This fixes an issue where there was a moment of nothing being focused when switching between the find and replace text fields.NSHostingView -> NSView -> SwiftUI Viewstructure, replacing it with anNSHostingViewsubclassFindPanelHostingViewthat hosts aFindPanelView.FindPanel->FindPanelHostingViewFindPanelViewsearch fields moved to:FindSearchFieldReplaceSearchFieldRelated Issues
Checklist
Screenshots