Various fixes

This commit is contained in:
Ilya Laktyushin 2024-10-27 15:32:23 +04:00
parent 54d084b9ab
commit b46667113c
2 changed files with 18 additions and 2 deletions

View File

@ -298,7 +298,7 @@ public final class HashtagListItemComponent: Component {
guard let component = self.component else {
return
}
component.action(component.hashtag, self)
component.action("\(component.hashtag) ", self)
}
func update(component: HashtagListItemComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {

View File

@ -2003,7 +2003,23 @@ public final class MessageInputPanelComponent: Component {
}
}
case let .hashtag(hashtag):
let _ = hashtag
var hashtagQueryRange: NSRange?
inner: for (range, type, _) in textInputStateContextQueryRangeAndType(inputState: inputState) {
if type == [.hashtag] {
hashtagQueryRange = range
break inner
}
}
if let range = hashtagQueryRange {
let inputText = NSMutableAttributedString(attributedString: inputState.inputText)
let replacementText = hashtag
inputText.replaceCharacters(in: range, with: replacementText)
let selectionPosition = range.lowerBound + (replacementText as NSString).length
textView.updateText(inputText, selectionRange: selectionPosition ..< selectionPosition)
}
}
}
}