Skip to content

Commit 0883074

Browse files
committed
fix comments
1 parent 1d6f808 commit 0883074

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Sources/CodeEditor/UXCodeTextViewRepresentable.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ struct UXCodeTextViewRepresentable : UXViewRepresentable {
118118
#endif
119119

120120
private func textViewDidChange(textView: UXTextView) {
121-
// This function may be called as a consequence of calling
122-
// `textView.setSelectedRange(_:)` in UXCodeTextViewRepresentable/updateTextView(_:)`.
123-
// Since this function might update the `parent.selection` `Binding`, which in
121+
// This function may be called as a consequence of updating the text string
122+
// in UXCodeTextViewRepresentable/updateTextView(_:)`.
123+
// Since this function might update the `parent.source` `Binding`, which in
124124
// turn might update a `State`, this would lead to undefined behavior.
125+
// (Changing a `State` during a `View` update is not permitted).
125126
guard !parent.isCurrentlyUpdatingView.value else {
126127
return
127128
}
@@ -147,10 +148,11 @@ struct UXCodeTextViewRepresentable : UXViewRepresentable {
147148
#endif
148149

149150
private func textViewDidChangeSelection(textView: UXCodeTextView) {
150-
// This function may be called as a consequence of calling
151-
// `textView.setSelectedRange(_:)` in UXCodeTextViewRepresentable/updateTextView(_:)`.
151+
// This function may be called as a consequence of updating the selected
152+
// range in UXCodeTextViewRepresentable/updateTextView(_:)`.
152153
// Since this function might update the `parent.selection` `Binding`, which in
153154
// turn might update a `State`, this would lead to undefined behavior.
155+
// (Changing a `State` during a `View` update is not permitted).
154156
guard !parent.isCurrentlyUpdatingView.value else {
155157
return
156158
}

0 commit comments

Comments
 (0)