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 = "" } } }