Skip to content

Fixes text binding update#160

Merged
thecoolwinter merged 1 commit intoCodeEditApp:mainfrom
miguel-arrf:main
Mar 14, 2023
Merged

Fixes text binding update#160
thecoolwinter merged 1 commit intoCodeEditApp:mainfrom
miguel-arrf:main

Conversation

@miguel-arrf
Copy link
Contributor

@miguel-arrf miguel-arrf commented Mar 12, 2023

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

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

The STTextViewDelegate  textDidChange function changed to textViewDidChangeText. Without this change, the text binding value isn't updated.
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.

2 participants

Comments