@kubohiroya/turbowarp-plus-editor-code-views 0.8.0 → 0.8.1
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.
|
@@ -29,16 +29,25 @@ export function attachSpriteRestoreHistory({ store, vm, limit = spriteRestoreLim
|
|
|
29
29
|
const previous = last;
|
|
30
30
|
last = current;
|
|
31
31
|
if (current.restoreFun) {
|
|
32
|
-
if (current.deletedItem
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
if (current.deletedItem !== sprite)
|
|
33
|
+
return;
|
|
34
|
+
const index = stack.indexOf(current.restoreFun);
|
|
35
|
+
if (index >= 0) {
|
|
36
|
+
// A restore function already kept came back to the slot: TurboWarp's delete
|
|
37
|
+
// confirmation puts the slot back as it was when the user cancels. The ones kept
|
|
38
|
+
// after it belong to deletions that did not happen.
|
|
39
|
+
stack.splice(index + 1);
|
|
40
|
+
return;
|
|
36
41
|
}
|
|
42
|
+
stack.push(current.restoreFun);
|
|
43
|
+
if (stack.length > Math.max(1, limit))
|
|
44
|
+
stack.splice(0, stack.length - Math.max(1, limit));
|
|
37
45
|
return;
|
|
38
46
|
}
|
|
39
47
|
// The menu restored what the slot held and cleared it.
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
const used = previous.restoreFun ? stack.indexOf(previous.restoreFun) : -1;
|
|
49
|
+
if (used >= 0)
|
|
50
|
+
stack.splice(used, 1);
|
|
42
51
|
const next = stack.at(-1);
|
|
43
52
|
if (next)
|
|
44
53
|
store.dispatch({ type: RESTORE_UPDATE, state: { restoreFun: next, deletedItem: sprite } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubohiroya/turbowarp-plus-editor-code-views",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Code views for TurboWarp Plus Editor: code in tabs and windows, the detached block palette, script layout and block field editing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -54,14 +54,22 @@ export function attachSpriteRestoreHistory({store, vm, limit = spriteRestoreLimi
|
|
|
54
54
|
const previous = last;
|
|
55
55
|
last = current;
|
|
56
56
|
if (current.restoreFun) {
|
|
57
|
-
if (current.deletedItem
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
if (current.deletedItem !== sprite) return;
|
|
58
|
+
const index = stack.indexOf(current.restoreFun);
|
|
59
|
+
if (index >= 0) {
|
|
60
|
+
// A restore function already kept came back to the slot: TurboWarp's delete
|
|
61
|
+
// confirmation puts the slot back as it was when the user cancels. The ones kept
|
|
62
|
+
// after it belong to deletions that did not happen.
|
|
63
|
+
stack.splice(index + 1);
|
|
64
|
+
return;
|
|
60
65
|
}
|
|
66
|
+
stack.push(current.restoreFun);
|
|
67
|
+
if (stack.length > Math.max(1, limit)) stack.splice(0, stack.length - Math.max(1, limit));
|
|
61
68
|
return;
|
|
62
69
|
}
|
|
63
70
|
// The menu restored what the slot held and cleared it.
|
|
64
|
-
|
|
71
|
+
const used = previous.restoreFun ? stack.indexOf(previous.restoreFun) : -1;
|
|
72
|
+
if (used >= 0) stack.splice(used, 1);
|
|
65
73
|
const next = stack.at(-1);
|
|
66
74
|
if (next) store.dispatch({type: RESTORE_UPDATE, state: {restoreFun: next, deletedItem: sprite}});
|
|
67
75
|
};
|