From 316969769f63404d7c203a93cda1ae43c4bd2845 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 14 Jun 2025 08:24:53 -0700 Subject: feat: Development commit --- Sora/Views/SearchSuggestionsView.swift | 13 +++++++------ 1 file 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) }) -- cgit v1.2.3