Skip to content

Commit ed1ffd9

Browse files
committed
refactor: extract statusline order helper
1 parent cb5f457 commit ed1ffd9

2 files changed

Lines changed: 23 additions & 18 deletions

File tree

lib/codex-manager/settings-hub.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ import {
7272
warnPersistFailure,
7373
} from "./settings-persist-utils.js";
7474
import { withQueuedRetry } from "./settings-write-queue.js";
75+
import { reorderStatuslineField } from "./statusline-order.js";
76+
77+
const reorderField = reorderStatuslineField;
78+
7579
import { promptStatuslineSettingsPanel } from "./statusline-settings-panel.js";
7680
import { promptThemeSettingsPanel } from "./theme-settings-panel.js";
7781

@@ -609,24 +613,6 @@ async function configureDashboardDisplaySettings(
609613
return merged;
610614
}
611615

612-
function reorderField(
613-
fields: DashboardStatuslineField[],
614-
key: DashboardStatuslineField,
615-
direction: -1 | 1,
616-
): DashboardStatuslineField[] {
617-
const index = fields.indexOf(key);
618-
if (index < 0) return fields;
619-
const target = index + direction;
620-
if (target < 0 || target >= fields.length) return fields;
621-
const next = [...fields];
622-
const current = next[index];
623-
const swap = next[target];
624-
if (!current || !swap) return fields;
625-
next[index] = swap;
626-
next[target] = current;
627-
return next;
628-
}
629-
630616
async function promptStatuslineSettings(
631617
initial: DashboardDisplaySettings,
632618
): Promise<DashboardDisplaySettings | null> {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { DashboardStatuslineField } from "../dashboard-settings.js";
2+
3+
export function reorderStatuslineField(
4+
fields: DashboardStatuslineField[],
5+
key: DashboardStatuslineField,
6+
direction: -1 | 1,
7+
): DashboardStatuslineField[] {
8+
const index = fields.indexOf(key);
9+
if (index < 0) return fields;
10+
const target = index + direction;
11+
if (target < 0 || target >= fields.length) return fields;
12+
const next = [...fields];
13+
const current = next[index];
14+
const swap = next[target];
15+
if (!current || !swap) return fields;
16+
next[index] = swap;
17+
next[target] = current;
18+
return next;
19+
}

0 commit comments

Comments
 (0)