Skip to content

Commit cce41f7

Browse files
committed
Validate Find Text Updating
1 parent 662a231 commit cce41f7

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Example/CodeEditSourceEditorExample/CodeEditSourceEditorExample/Views/StatusBar.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ struct StatusBar: View {
109109
Divider()
110110
.frame(height: 12)
111111

112+
Text(state.findText ?? "")
113+
.frame(maxWidth: 30)
114+
.lineLimit(1)
115+
.truncationMode(.head)
116+
.foregroundStyle(.secondary)
117+
112118
Button {
113119
state.findPanelVisible.toggle()
114120
} label: {

Sources/CodeEditSourceEditor/SourceEditor/SourceEditor.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,6 @@ public struct SourceEditor: NSViewControllerRepresentable {
118118

119119
public func updateNSViewController(_ controller: TextViewController, context: Context) {
120120
context.coordinator.updateHighlightProviders(highlightProviders)
121-
print(
122-
context.coordinator.isUpdateFromTextView,
123-
state.findPanelVisible,
124-
controller.findViewController?.viewModel.isShowingFindPanel ?? false
125-
)
126121

127122
// Prevent infinite loop of update notifications
128123
if context.coordinator.isUpdateFromTextView {
@@ -137,7 +132,7 @@ public struct SourceEditor: NSViewControllerRepresentable {
137132
controller.gutterView.needsDisplay = true
138133
}
139134

140-
if let findText = state.findText {
135+
if let findText = state.findText, findText != state.findText {
141136
controller.findViewController?.viewModel.findText = findText
142137
}
143138

0 commit comments

Comments
 (0)