Fix cursor jumping when pressing return
Changelog-Fixed: Fix cursor jumping when pressing return Closes: #775
This commit is contained in:
@@ -25,6 +25,7 @@ struct UserSearch: View {
|
||||
@Binding var postTextViewCanScroll: Bool
|
||||
|
||||
@Binding var post: NSMutableAttributedString
|
||||
@EnvironmentObject var tagModel: TagModel
|
||||
|
||||
var users: [SearchedUser] {
|
||||
guard let contacts = damus_state.contacts.event else {
|
||||
@@ -48,6 +49,9 @@ struct UserSearch: View {
|
||||
}
|
||||
let mutableString = NSMutableAttributedString(attributedString: post)
|
||||
mutableString.replaceCharacters(in: wordRange, with: tagAttributedString)
|
||||
///adjust cursor position appropriately: ('diff' used in TextViewWrapper / updateUIView after below update of 'post')
|
||||
tagModel.diff = tagAttributedString.length - wordRange.length
|
||||
|
||||
post = mutableString
|
||||
focusWordAttributes = (nil, nil)
|
||||
newCursorIndex = wordRange.location + tagAttributedString.string.count
|
||||
|
||||
Reference in New Issue
Block a user