diff --git a/exampleFiles/SPINUPfield.pawdraw b/exampleFiles/SPINUPfield.pawdraw
deleted file mode 100644
index a5c5c6b..0000000
--- a/exampleFiles/SPINUPfield.pawdraw
+++ /dev/null
@@ -1 +0,0 @@
-[{"position":{"marginOfError":5.81340425804592,"x":78,"y":22,"heading":-89},"actions":[0]},{"position":{"marginOfError":20.256234283143364,"x":83,"y":101,"heading":0}},{"position":{"marginOfError":9.326487700546172,"x":134,"y":58,"heading":97},"actions":[0]}]
\ No newline at end of file
diff --git a/exampleFiles/SPINUPfield.vauto b/exampleFiles/SPINUPfield.vauto
new file mode 100644
index 0000000..cd6d653
--- /dev/null
+++ b/exampleFiles/SPINUPfield.vauto
@@ -0,0 +1 @@
+[{"position":{"x":69,"y":98,"heading":-101,"marginOfError":8.981606814793919},"actions":[0,1,3,2,4]},{"position":{"x":72,"y":72,"heading":0,"marginOfError":6}},{"position":{"x":83,"y":101,"heading":0,"marginOfError":20.256234283143364}},{"position":{"x":134,"y":58,"heading":97,"marginOfError":9.326487700546172},"actions":[0]}]
\ No newline at end of file
diff --git a/media/SpinUpField.svg b/media/SpinUpField.svg
index 570b95c..a4de78e 100644
--- a/media/SpinUpField.svg
+++ b/media/SpinUpField.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/package.json b/package.json
index 7e6a5bf..1976f7a 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,7 @@
"displayName": "Paw Draw",
"selector": [
{
- "filenamePattern": "*.pawdraw"
+ "filenamePattern": "*.vauto"
}
]
}
diff --git a/src/webview/eventList.ts b/src/webview/eventList.ts
index 23b334b..4b0b9eb 100644
--- a/src/webview/eventList.ts
+++ b/src/webview/eventList.ts
@@ -1,4 +1,3 @@
-import { EventEmitter } from "events";
export enum LIST_ACTION_TYPE {
APPEND,
INSERT,
diff --git a/src/webview/listManager.ts b/src/webview/listManager.ts
index efb4972..d27ae1f 100644
--- a/src/webview/listManager.ts
+++ b/src/webview/listManager.ts
@@ -181,7 +181,7 @@ export default class ListManager {
/** checks if index is in bounds, if not, it will return it in bounds using modulo*/
public _fixIndexWrap(index: number = this.index): number {
return (index =
- (index < 0 ? this.list.length - 1 : 0) + (index % this.list.length));
+ (index < 0 ? this.list.length : 0) + (index % this.list.length));
}
/** checks if index is in bounds, if not, it will return it in bounds by shifting the number in bounds*/
public _fixIndexShift(index: number = this.index): number {
@@ -252,7 +252,18 @@ export default class ListManager {
this.appendNode(this.newNode);
}
public insertNewNodeAfterCur() {
- this.insertAfterCurNode(this.newNode);
+ this.insertAfterCurNode(
+ structuredClone({
+ actions: this.newNode.actions,
+ position: {
+ ...this.getCurNode().position,
+ marginOfError:
+ this.getCurError() < 1
+ ? this.newNode.position.marginOfError
+ : this.getCurError(),
+ },
+ })
+ );
}
public get index(): number {
return this._index;
diff --git a/src/webview/nodeList.ts b/src/webview/nodeList.ts
index b3f39bd..94d5aac 100644
--- a/src/webview/nodeList.ts
+++ b/src/webview/nodeList.ts
@@ -1,21 +1,43 @@
import EventList, { ListAction } from "./eventList.js";
// import Message from "../common/message.js";
-import { Node } from "../common/node.js";
+import { Node as MyNode } from "../common/node.js";
+import { HasMarginOfError, Position } from "../common/coordinates";
-export default class NodeList extends EventList {
- private startList: Node[];
- public constructor(arr: Node[] = []) {
+export default class NodeList extends EventList {
+ private startList: MyNode[];
+ public constructor(arr: MyNode[] = []) {
super(arr);
this.startList = structuredClone(arr);
}
- public toJSON(): Node[] {
+ public toJSON(): MyNode[] {
// console.log(this)
- return super.get({ all: true });
+ return super.get({ all: true }).map((node: MyNode) => {
+ return {
+ position: Object.fromEntries(
+ Object.entries(node.position).sort(([k1], [k2]) => {
+ function getVal(key: string): number {
+ switch (key as "x" | "y" | "heading" | "marginOfError") {
+ case "x":
+ return 4;
+ case "y":
+ return 3;
+ case "heading":
+ return 2;
+ case "marginOfError":
+ return 1;
+ }
+ }
+ return getVal(k2) - getVal(k1);
+ })
+ ) as Position & HasMarginOfError,
+ actions: node.actions,
+ };
+ });
}
- public update(content?: Node[], edits?: ListAction[]) {
+ public update(content?: MyNode[], edits?: ListAction[]) {
// console.log("edits", edits, "arr", this.startList);
if (content) {
this.setList(content);