From 073dd8a39974d19e482a093c2f070d18deca3cc7 Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Mon, 13 Apr 2026 12:39:32 +0200 Subject: [PATCH] macOS: trim query before filtering commands --- .../Features/Command Palette/CommandPalette.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/macos/Sources/Features/Command Palette/CommandPalette.swift b/macos/Sources/Features/Command Palette/CommandPalette.swift index 7321745a7..de440fdc3 100644 --- a/macos/Sources/Features/Command Palette/CommandPalette.swift +++ b/macos/Sources/Features/Command Palette/CommandPalette.swift @@ -61,10 +61,14 @@ struct CommandPaletteView: View { @Binding var isPresented: Bool var backgroundColor: Color = Color(nsColor: .windowBackgroundColor) var options: [CommandOption] - @State private var query = "" + @State private var rawQuery = "" @State private var selectedIndex: UInt? @State private var hoveredOptionID: UUID? + var query: String { + rawQuery.trimmingCharacters(in: .whitespacesAndNewlines) + } + // The options that we should show, taking into account any filtering from // the query. Options with matching leadingColor are ranked higher. var filteredOptions: [CommandOption] { @@ -104,7 +108,7 @@ struct CommandPaletteView: View { } VStack(alignment: .leading, spacing: 0) { - CommandPaletteQuery(query: $query) { event in + CommandPaletteQuery(query: $rawQuery) { event in switch event { case .exit: isPresented = false @@ -182,7 +186,7 @@ struct CommandPaletteView: View { // This is optional, since most of the time // there will be a delay before the next use. // To keep behavior the same as before, we reset it. - query = "" + rawQuery = "" } } }