diff options
| author | Fuwn <[email protected]> | 2025-06-14 08:24:53 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-06-14 08:24:53 -0700 |
| commit | 316969769f63404d7c203a93cda1ae43c4bd2845 (patch) | |
| tree | 0e9f63cdd137124ab3d9738e901cb0cd36d6e9b9 | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-316969769f63404d7c203a93cda1ae43c4bd2845.tar.xz sora-testing-316969769f63404d7c203a93cda1ae43c4bd2845.zip | |
feat: Development commit
| -rw-r--r-- | Sora/Views/SearchSuggestionsView.swift | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Sora/Views/SearchSuggestionsView.swift b/Sora/Views/SearchSuggestionsView.swift index d30303f..c5210a6 100644 --- a/Sora/Views/SearchSuggestionsView.swift +++ b/Sora/Views/SearchSuggestionsView.swift @@ -56,19 +56,20 @@ struct SearchSuggestionsView: View { switch item { case .left(let tag): Button { - if let range = searchText.range(of: lastSearchTag, options: .backwards) { - searchText.replaceSubrange(range, with: tag.name) - } + let previousTags = searchText.split(separator: " ").dropLast() + + searchText = (previousTags.map(String.init) + [tag.name]).joined(separator: " ") } label: { Text(tag.name) } case .right(let query): Button { - if let range = searchText.range(of: lastSearchTag, options: .backwards), - let matchingTag = query.tags.first(where: { $0.lowercased().contains(lastSearchTag) }) + if let matchingTag = query.tags.first(where: { $0.lowercased().contains(lastSearchTag) }) { - searchText.replaceSubrange(range, with: matchingTag) + let previousTags = searchText.split(separator: " ").dropLast() + + searchText = (previousTags.map(String.init) + [matchingTag]).joined(separator: " ") } } label: { if let matchingTag = query.tags.first(where: { $0.lowercased().contains(lastSearchTag) }) |