Skip to content

Find: Replace and Match Case Toggle #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
May 9, 2025
Merged

Find: Replace and Match Case Toggle #301

merged 40 commits into from
May 9, 2025

Conversation

austincondiff
Copy link
Collaborator

@austincondiff austincondiff commented Apr 10, 2025

Description

This PR adds the following functionality to the source editor find panel:

  • Replace: Enables replacing matched text with the specified replacement.
  • Toggle Match Navigation Wrap-Around: Allows cycling through matches from the beginning when reaching the end.
  • Toggle Match Case: Adds an option to filter matches by case sensitivity.
  • Made find panel responsive at small sizes using ViewThatFits.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Screen.Recording.2025-05-05.at.10.20.48.PM.mov
Screen.Recording.2025-05-05.at.10.28.16.PM.mov

austincondiff and others added 27 commits April 10, 2025 18:20
### 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 -->
### 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 -->
Copy link
Collaborator

@thecoolwinter thecoolwinter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The find subviews are getting numerous, could we write some documentation for each view to help disambiguate what each one is doing?

Copy link
Member

@tom-ludwig tom-ludwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add previews to some of the SwiftUI views?

Copy link
Collaborator

@thecoolwinter thecoolwinter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small find

Copy link
Member

@tom-ludwig tom-ludwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. So happy to get this merged.

@austincondiff austincondiff merged commit b96f270 into main May 9, 2025
2 checks passed
@austincondiff austincondiff deleted the feat/find-replace branch May 9, 2025 16:25
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.

3 participants