GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): port #10158 to V2 — Usage shortcuts sort the same whatever … · pingdotgg/t3code@1b10d08

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components/settings
    • KeybindingsSettings.logic.test.ts
    • KeybindingsSettings.logic.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/settings/KeybindingsSettings.logic.test.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/settings/KeybindingsSettings.logic.test.ts
+11-6Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,25 @@ describe("KeybindingsSettings.logic", () => {
6060
);
6161
it("orders Usage bindings and command choices like the page", () => {
6262
const expected = [
63-
"usage.cost",
6463
"usage.open",
64+
"usage.cost",
6565
"usage.tokens",
6666
"usage.limits",
6767
"usage.period.day",
6868
"usage.period.week",
6969
"usage.period.month",
7070
"usage.period.quarter",
7171
];
72-
const bindings = DEFAULT_RESOLVED_KEYBINDINGS.toReversed();
73-
expect(buildKeybindingRows(bindings, "usage").map((row) => row.command)).toEqual(expected);
74-
expect(
75-
buildKeybindingCommandOptions(bindings).filter((command) => command.startsWith("usage.")),
76-
).toEqual(expected);
72+
// The order must not depend on the order of the configured bindings.
73+
for (const bindings of [
74+
DEFAULT_RESOLVED_KEYBINDINGS,
75+
DEFAULT_RESOLVED_KEYBINDINGS.toReversed(),
76+
]) {
77+
expect(buildKeybindingRows(bindings, "usage").map((row) => row.command)).toEqual(expected);
78+
expect(
79+
buildKeybindingCommandOptions(bindings).filter((command) => command.startsWith("usage.")),
80+
).toEqual(expected);
81+
}
7782
});
7883

7984
it("builds searchable rows with readable key and when values", () => {
Collapse file

‎apps/web/src/components/settings/KeybindingsSettings.logic.ts‎

Copy file name to clipboardExpand all lines: apps/web/src/components/settings/KeybindingsSettings.logic.ts
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ import { shortcutKeyFromEvent } from "../../keybindings";
1515
import { isMacPlatform } from "../../lib/utils";
1616
import { METRIC_OPTIONS, WINDOW_OPTIONS } from "../usage/usageShortcuts";
1717

18+
// Every usage.* command needs a rank. An unranked one falls back to the
19+
// alphabetical compare, which makes the comparator inconsistent and the order
20+
// depend on the input order.
1821
const usageCommandOrder = new Map<KeybindingCommand, number>(
19-
[...METRIC_OPTIONS, ...WINDOW_OPTIONS].map((option, index) => [option.command, index]),
22+
[
23+
"usage.open" as const,
24+
...[...METRIC_OPTIONS, ...WINDOW_OPTIONS].map((option) => option.command),
25+
].map((command, index) => [command, index]),
2026
);
2127

2228
function compareUsageCommands(left: KeybindingCommand, right: KeybindingCommand): number | null {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.