-
Notifications
You must be signed in to change notification settings - Fork 116
Labels
triagePending for triagingPending for triaging
Description
What happened?
The array branch in updateYTypeFromObject(...) assumes only a single update happens at a time. It compares the old and new arrays from the front until the first mismatch, then performs only a single delete(...) or insert(...).
texera/frontend/src/app/workspace/types/shared-editing.interface.ts
Lines 130 to 164 in ac909a0
| } else if (newObjType === "Array") { | |
| // TODO: Fix this | |
| const oldYObjAsYArray = oldYObj as unknown as Y.Array<any>; | |
| const newObjAsArr = newObj as any[]; | |
| const newArrLen = newObjAsArr.length; | |
| const oldObjAsArr = oldYObjAsYArray.toJSON(); | |
| const oldArrLen = oldObjAsArr.length; | |
| // TODO: in-place update, assuming only one update at a time can happen. | |
| if (newArrLen < oldArrLen) { | |
| let i = 0; | |
| for (i; i < newArrLen; i++) { | |
| if (!_.isEqual(oldObjAsArr[i], newObjAsArr[i])) break; | |
| } | |
| oldYObjAsYArray.delete(i); | |
| } else if (newArrLen > oldArrLen) { | |
| let i = 0; | |
| for (i; i < newArrLen; i++) { | |
| if (!_.isEqual(oldObjAsArr[i], newObjAsArr[i])) break; | |
| } | |
| oldYObjAsYArray.insert(i, [createYTypeFromObject(newObjAsArr[i])]); | |
| } else { | |
| for (let i = 0; i < newArrLen; i++) { | |
| if (!_.isEqual(oldObjAsArr[i], newObjAsArr[i])) { | |
| if (!updateYTypeFromObject(oldYObjAsYArray.get(i), newObjAsArr[i])) { | |
| if (newObjAsArr[i] !== undefined) { | |
| oldYObjAsYArray.delete(i, 1); | |
| const res = createYTypeFromObject(newObjAsArr[i]); | |
| if (res === undefined) oldYObjAsYArray.insert(i, [null]); | |
| else oldYObjAsYArray.insert(i, [res]); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } else if (newObjType === "Object") { |
How to reproduce?
Could not find a way to be reproduced in current repo.
Version
1.1.0-incubating (Pre-release/Master)
Commit Hash (Optional)
No response
What browsers are you seeing the problem on?
No response
Relevant log output
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
triagePending for triagingPending for triaging