mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 01:06:08 +03:00
order commands alphabetically and preserve capitalization
This commit is contained in:
@ -197,7 +197,7 @@ fileprivate struct CommandRow: View {
|
||||
var body: some View {
|
||||
Button(action: action) {
|
||||
HStack {
|
||||
Text(option.title.lowercased())
|
||||
Text(option.title)
|
||||
Spacer()
|
||||
if let shortcut = option.shortcut {
|
||||
Text(shortcut)
|
||||
|
@ -38,9 +38,19 @@ pub const Command = struct {
|
||||
.description = self.description,
|
||||
};
|
||||
}
|
||||
|
||||
/// Implements a comparison function for std.mem.sortUnstable
|
||||
/// and similar functions. The sorting is defined by Ghostty
|
||||
/// to be what we prefer. If a caller wants some other sorting,
|
||||
/// they should do it themselves.
|
||||
pub fn lessThan(_: void, lhs: Command, rhs: Command) bool {
|
||||
return std.ascii.orderIgnoreCase(lhs.title, rhs.title) == .lt;
|
||||
}
|
||||
};
|
||||
|
||||
pub const defaults: []const Command = defaults: {
|
||||
@setEvalBranchQuota(100_000);
|
||||
|
||||
var count: usize = 0;
|
||||
for (@typeInfo(Action.Key).@"enum".fields) |field| {
|
||||
const action = @field(Action.Key, field.name);
|
||||
@ -58,6 +68,8 @@ pub const defaults: []const Command = defaults: {
|
||||
}
|
||||
}
|
||||
|
||||
std.mem.sortUnstable(Command, &result, {}, Command.lessThan);
|
||||
|
||||
assert(i == count);
|
||||
const final = result;
|
||||
break :defaults &final;
|
||||
|
Reference in New Issue
Block a user