summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-06-14 08:24:53 -0700
committerFuwn <[email protected]>2025-06-14 08:24:53 -0700
commit316969769f63404d7c203a93cda1ae43c4bd2845 (patch)
tree0e9f63cdd137124ab3d9738e901cb0cd36d6e9b9
parentfeat: Development commit (diff)
downloadsora-testing-316969769f63404d7c203a93cda1ae43c4bd2845.tar.xz
sora-testing-316969769f63404d7c203a93cda1ae43c4bd2845.zip
feat: Development commit
-rw-r--r--Sora/Views/SearchSuggestionsView.swift13
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) })