X-Git-Url: https://git.r.bdr.sh/rbdr/map/blobdiff_plain/144915635bdfc90445321189914929a911fe77d4..ed10ac191df473c92c4fec495aafa7f569d108c8:/Map/Presentation/MapEditor.swift?ds=sidebyside diff --git a/Map/Presentation/MapEditor.swift b/Map/Presentation/MapEditor.swift index d7c93dd..5cda8f9 100644 --- a/Map/Presentation/MapEditor.swift +++ b/Map/Presentation/MapEditor.swift @@ -1,19 +1,17 @@ -/* - Copyright (C) 2024 Rubén Beltrán del Río - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see https://map.tranquil.systems. - */ +// Copyright (C) 2024 Rubén Beltrán del Río + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see https://map.tranquil.systems. import SwiftUI struct MapEditor: View { @@ -22,6 +20,8 @@ struct MapEditor: View { @State var selectedEvolution: StageType = .behavior @State var isSearching: Bool = false + private let changeDebouncer: Debouncer = Debouncer(seconds: 0.05) + @AppStorage("viewStyle") var viewStyle: ViewStyle = .horizontal let zoomRange = Constants.kMinZoom...Constants.kMaxZoom @@ -30,9 +30,11 @@ struct MapEditor: View { @State var searchTerm = "" @State var selectedTerm = 0 - var results: [Range] { + @State var results: [Range] = [] + + private func updateRanges() { if !isSearching || searchTerm.isEmpty { - return [] + results = [] } let options: NSString.CompareOptions = [.caseInsensitive, .diacriticInsensitive] var searchRange = document.text.startIndex..