mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-18 01:36: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 {
|
var body: some View {
|
||||||
Button(action: action) {
|
Button(action: action) {
|
||||||
HStack {
|
HStack {
|
||||||
Text(option.title.lowercased())
|
Text(option.title)
|
||||||
Spacer()
|
Spacer()
|
||||||
if let shortcut = option.shortcut {
|
if let shortcut = option.shortcut {
|
||||||
Text(shortcut)
|
Text(shortcut)
|
||||||
|
@ -38,9 +38,19 @@ pub const Command = struct {
|
|||||||
.description = self.description,
|
.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: {
|
pub const defaults: []const Command = defaults: {
|
||||||
|
@setEvalBranchQuota(100_000);
|
||||||
|
|
||||||
var count: usize = 0;
|
var count: usize = 0;
|
||||||
for (@typeInfo(Action.Key).@"enum".fields) |field| {
|
for (@typeInfo(Action.Key).@"enum".fields) |field| {
|
||||||
const action = @field(Action.Key, field.name);
|
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);
|
assert(i == count);
|
||||||
const final = result;
|
const final = result;
|
||||||
break :defaults &final;
|
break :defaults &final;
|
||||||
|
Reference in New Issue
Block a user