poe-code 4.0.37 → 4.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -8,8 +8,11 @@ export function buildPlanExplorerConfig(options) {
|
|
|
8
8
|
let plans = options.plans;
|
|
9
9
|
let rows = toRows(plans);
|
|
10
10
|
let entryByRowId = toEntryMap(plans);
|
|
11
|
+
let preserveOrderOnNextRefresh = false;
|
|
11
12
|
async function refresh() {
|
|
12
|
-
|
|
13
|
+
const refreshedPlans = await options.onRefresh();
|
|
14
|
+
plans = preserveOrderOnNextRefresh ? preservePlanOrder(plans, refreshedPlans) : refreshedPlans;
|
|
15
|
+
preserveOrderOnNextRefresh = false;
|
|
13
16
|
rows = toRows(plans);
|
|
14
17
|
entryByRowId = toEntryMap(plans);
|
|
15
18
|
}
|
|
@@ -22,7 +25,13 @@ export function buildPlanExplorerConfig(options) {
|
|
|
22
25
|
const entry = getEntry(entryByRowId, ctx.row.id);
|
|
23
26
|
const readiness = entry.readiness === "ready" ? "draft" : "ready";
|
|
24
27
|
await setPlanReadiness(entry.absolutePath, readiness, options.fs);
|
|
25
|
-
|
|
28
|
+
preserveOrderOnNextRefresh = true;
|
|
29
|
+
try {
|
|
30
|
+
await ctx.refresh();
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
preserveOrderOnNextRefresh = false;
|
|
34
|
+
}
|
|
26
35
|
ctx.toast(`Marked ${path.basename(entry.path)} ${readiness}`, "info");
|
|
27
36
|
}
|
|
28
37
|
},
|
|
@@ -100,6 +109,7 @@ export function buildPlanExplorerConfig(options) {
|
|
|
100
109
|
},
|
|
101
110
|
{
|
|
102
111
|
id: "delete",
|
|
112
|
+
accelerator: "x",
|
|
103
113
|
label: "Delete",
|
|
104
114
|
destructive: true,
|
|
105
115
|
handler: async (ctx) => {
|
|
@@ -148,6 +158,24 @@ export function buildPlanExplorerConfig(options) {
|
|
|
148
158
|
emptyHint: "No plans found"
|
|
149
159
|
});
|
|
150
160
|
}
|
|
161
|
+
function preservePlanOrder(current, refreshed) {
|
|
162
|
+
const refreshedByPath = new Map();
|
|
163
|
+
for (const entry of refreshed) {
|
|
164
|
+
const matches = refreshedByPath.get(entry.absolutePath) ?? [];
|
|
165
|
+
matches.push(entry);
|
|
166
|
+
refreshedByPath.set(entry.absolutePath, matches);
|
|
167
|
+
}
|
|
168
|
+
const ordered = [];
|
|
169
|
+
for (const entry of current) {
|
|
170
|
+
const matches = refreshedByPath.get(entry.absolutePath);
|
|
171
|
+
const match = matches?.shift();
|
|
172
|
+
if (match !== undefined)
|
|
173
|
+
ordered.push(match);
|
|
174
|
+
}
|
|
175
|
+
const remaining = new Set(ordered);
|
|
176
|
+
ordered.push(...refreshed.filter((entry) => !remaining.has(entry)));
|
|
177
|
+
return ordered;
|
|
178
|
+
}
|
|
151
179
|
function abbreviateHome(filePath, homeDir) {
|
|
152
180
|
if (homeDir === undefined)
|
|
153
181
|
return filePath;
|
|
@@ -786,14 +786,15 @@ function dispatchAction(state, action, confirmed, runtimeHandles, modalRows) {
|
|
|
786
786
|
return mark(state, 0);
|
|
787
787
|
}
|
|
788
788
|
if (action.destructive === true && !confirmed) {
|
|
789
|
+
const actionLabel = typeof action.label === "function" ? action.label() : action.label;
|
|
789
790
|
return {
|
|
790
791
|
state: {
|
|
791
792
|
...state,
|
|
792
793
|
modal: {
|
|
793
794
|
kind: "confirm",
|
|
794
795
|
title: action.destructive ? "Confirm destructive action" : "Confirm action",
|
|
795
|
-
message: `${
|
|
796
|
-
confirmLabel:
|
|
796
|
+
message: `${actionLabel} ${rows.length === 1 ? rows[0].title : `${rows.length} items`}?`,
|
|
797
|
+
confirmLabel: actionLabel,
|
|
797
798
|
cancelLabel: "Cancel",
|
|
798
799
|
destructive: action.destructive === true,
|
|
799
800
|
action,
|