Skip to content

Commit 58bca71

Browse files
Mentions of users available in a new line
1 parent f7f1b01 commit 58bca71

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1111
### 🐞 Fixed
1212
- Channel actions popup wrong appearance using a custom `NavigationView`
1313
- Channel list automatic channel selection disabled for compact iPad screen size
14+
- Mentions of users available in a new line
1415

1516
# [4.28.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.28.0)
1617
_February 28, 2023_

Sources/StreamChatSwiftUI/ChatChannel/Composer/Suggestions/TypingSuggester.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public struct TypingSuggester {
9898
let charIndexBeforeSymbol = firstSymbolBeforeCaret.lowerBound - 1
9999
let charRangeBeforeSymbol = NSRange(location: charIndexBeforeSymbol, length: 1)
100100
let textBeforeSymbol = charIndexBeforeSymbol >= 0 ? textString.substring(with: charRangeBeforeSymbol) : ""
101-
guard textBeforeSymbol.isEmpty || textBeforeSymbol == " " else {
101+
guard textBeforeSymbol.isEmpty || textBeforeSymbol == " " || textBeforeSymbol == "\n" else {
102102
return nil
103103
}
104104

StreamChatSwiftUITests/Tests/ChatChannel/Suggestions/TypingSuggester_Tests.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,24 @@ class TypingSuggester_Tests: XCTestCase {
133133
XCTAssert(suggestion?.text == "Mar")
134134
XCTAssert(suggestion?.locationRange == NSRange(location: 5, length: 3))
135135
}
136+
137+
func test_typingSuggester_newLine() {
138+
// Given
139+
let options = TypingSuggestionOptions(symbol: "@")
140+
let typingSuggester = TypingSuggester(options: options)
141+
let string = "\n@Mar"
142+
let caretLocation = 5
143+
144+
// When
145+
let suggestion = typingSuggester.typingSuggestion(
146+
in: string,
147+
caretLocation: caretLocation
148+
)
149+
150+
// Then
151+
XCTAssert(suggestion?.text == "Mar")
152+
XCTAssert(suggestion?.locationRange == NSRange(location: 2, length: 3))
153+
}
136154

137155
func test_typingSuggester_onlyOnStartAllowed() {
138156
// Given

0 commit comments

Comments
 (0)