Skip to content

Commit b0d23bf

Browse files
authored
Fixes text binding update (#160)
<!--- IMPORTANT: If this PR addresses multiple unrelated issues, it will be closed until separated. --> ### Description The STTextViewDelegate textDidChange function changed to textViewDidChangeText. Without this change, the text binding value wasn't updated. Before, in a situation like the one below, the prompt variable was never updated since the delegate function was not called because of the mismatched signature. ``` @State var prompt: String = "..." (...) CodeEditTextView( $prompt, language: .default, theme: $theme, font: $font, tabWidth: $tabWidth, lineHeight: $lineHeight, wrapLines: .constant(true), editorOverscroll: $editorOverscroll ) .onChange(of: prompt, perform: { promptUpdate in print(promptUpdate) }) ``` With the proposed update, the behaviour is as expected. The `onChange` is now triggered. The STTextViewDelegate: [https://github.com/krzyzanowskim/STTextView/blob/main/Sources/STTextView/STTextViewDelegate.swift](https://github.com/krzyzanowskim/STTextView/blob/main/Sources/STTextView/STTextViewDelegate.swift) <!--- REQUIRED: Describe what changed in detail --> ### 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) - [ ] 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 - [ ] My changes are all related to the related issue above - [x] I documented my code Author: @miguel-arrf Approved by: @thecoolwinter
1 parent c6d67a2 commit b0d23bf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/CodeEditTextView/STTextViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public class STTextViewController: NSViewController, STTextViewDelegate, ThemeAt
183183
super.viewDidAppear()
184184
}
185185

186-
public func textDidChange(_ notification: Notification) {
186+
public func textViewDidChangeText(_ notification: Notification) {
187187
self.text.wrappedValue = textView.string
188188
}
189189

0 commit comments

Comments
 (0)