From b30e94c0ece807b2a8af006758842db446ba8722 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 17 Dec 2025 09:32:39 -0800 Subject: [PATCH] macos: sort in the focus jumps in other commands --- .../Command Palette/TerminalCommandPalette.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/macos/Sources/Features/Command Palette/TerminalCommandPalette.swift b/macos/Sources/Features/Command Palette/TerminalCommandPalette.swift index e3da9ff56..6d6a89162 100644 --- a/macos/Sources/Features/Command Palette/TerminalCommandPalette.swift +++ b/macos/Sources/Features/Command Palette/TerminalCommandPalette.swift @@ -63,9 +63,16 @@ struct TerminalCommandPaletteView: View { /// All commands available in the command palette, combining update and terminal options. private var commandOptions: [CommandOption] { var options: [CommandOption] = [] + // Updates always appear first options.append(contentsOf: updateOptions) - options.append(contentsOf: jumpOptions) - options.append(contentsOf: terminalOptions) + + // Sort the rest. We replace ":" with a character that sorts before space + // so that "Foo:" sorts before "Foo Bar:". + options.append(contentsOf: (jumpOptions + terminalOptions).sorted { a, b in + let aNormalized = a.title.replacingOccurrences(of: ":", with: "\t") + let bNormalized = b.title.replacingOccurrences(of: ":", with: "\t") + return aNormalized.localizedCaseInsensitiveCompare(bNormalized) == .orderedAscending + }) return options }