Commit 3bd9c71
authored
Find and Replace Refactor (#311)
### 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 -->1 parent a67b451 commit 3bd9c71
File tree
24 files changed
+699
-934
lines changed- Sources/CodeEditSourceEditor
- Controller
- Find
- PanelView
- ViewModel
- SupportingViews
24 files changed
+699
-934
lines changedLines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| |||
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
20 | | - | |
21 | | - | |
22 | | - | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
| 195 | + | |
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| |||
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
100 | 104 | | |
101 | 105 | | |
102 | 106 | | |
| |||
Lines changed: 0 additions & 24 deletions
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
22 | 23 | | |
Lines changed: 0 additions & 221 deletions
This file was deleted.
0 commit comments