Skip to content

Commit 5e8f5fd

Browse files
committed
Merge PR #261: refactor: extract statusline order helper
2 parents f7f807c + ed1ffd9 commit 5e8f5fd

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
@@ -91,6 +91,10 @@ import {
9191
normalizeStatuslineFields,
9292
} from "./settings-preview.js";
9393
import { withQueuedRetry } from "./settings-write-queue.js";
94+
import { reorderStatuslineField } from "./statusline-order.js";
95+
96+
const reorderField = reorderStatuslineField;
97+
9498
import { promptStatuslineSettingsPanel } from "./statusline-settings-panel.js";
9599
import { promptThemeSettingsPanel } from "./theme-settings-panel.js";
96100
import {
@@ -481,24 +485,6 @@ async function configureDashboardDisplaySettings(
481485
});
482486
}
483487

484-
function reorderField(
485-
fields: DashboardStatuslineField[],
486-
key: DashboardStatuslineField,
487-
direction: -1 | 1,
488-
): DashboardStatuslineField[] {
489-
const index = fields.indexOf(key);
490-
if (index < 0) return fields;
491-
const target = index + direction;
492-
if (target < 0 || target >= fields.length) return fields;
493-
const next = [...fields];
494-
const current = next[index];
495-
const swap = next[target];
496-
if (!current || !swap) return fields;
497-
next[index] = swap;
498-
next[target] = current;
499-
return next;
500-
}
501-
502488
async function promptStatuslineSettings(
503489
initial: DashboardDisplaySettings,
504490
): 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)