We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fromPath
toPath
tree.edit
What happened:
When performing a tree.edit operation, the fromPath and toPath values in document event are sometimes calculated incorrectly.
To reproduce the issue, you can run the following test code:
it.only('Should return correct range path within doc.subscribe', async function ({ task, }) { await withTwoClientsAndDocuments<{ t: Tree }>(async (c1, d1, c2, d2) => { d1.update((root) => { root.t = new Tree({ type: 'r', children: [ { type: 'c', children: [ { type: 'u', children: [ { type: 'p', children: [ { type: 'n', children: [], }, ], }, ], }, ], }, { type: 'c', children: [ { type: 'p', children: [ { type: 'n', children: [], }, ], }, ], }, ], }); }); await c1.sync(); await c2.sync(); assert.equal( d1.getRoot().t.toXML(), /*html*/ `<r><c><u><p><n></n></p></u></c><c><p><n></n></p></c></r>`, ); assert.equal( d2.getRoot().t.toXML(), /*html*/ `<r><c><u><p><n></n></p></u></c><c><p><n></n></p></c></r>`, ); d2.update((r) => r.t.editByPath([1, 0, 0, 0], [1, 0, 0, 0], { type: 'text', value: '1', }), ); d2.update((r) => r.t.editByPath([1, 0, 0, 1], [1, 0, 0, 1], { type: 'text', value: '2', }), ); d2.update((r) => r.t.editByPath([1, 0, 0, 2], [1, 0, 0, 2], { type: 'text', value: '3', }), ); await c2.sync(); await c1.sync(); assert.equal( d1.getRoot().t.toXML(), /*html*/ `<r><c><u><p><n></n></p></u></c><c><p><n>123</n></p></c></r>`, ); assert.equal( d2.getRoot().t.toXML(), /*html*/ `<r><c><u><p><n></n></p></u></c><c><p><n>123</n></p></c></r>`, ); d1.update((r) => r.t.editByPath([1, 0, 0, 1], [1, 0, 0, 1], { type: 'text', value: 'abcdefgh', }), ); await c1.sync(); await c2.sync(); assert.equal( d1.getRoot().t.toXML(), /*html*/ `<r><c><u><p><n></n></p></u></c><c><p><n>1abcdefgh23</n></p></c></r>`, ); assert.equal( d2.getRoot().t.toXML(), /*html*/ `<r><c><u><p><n></n></p></u></c><c><p><n>1abcdefgh23</n></p></c></r>`, ); d2.update((r) => r.t.editByPath([1, 0, 0, 5], [1, 0, 0, 5], { type: 'text', value: '4', }), ); d2.update((r) => r.t.editByPath([1, 0, 0, 6], [1, 0, 0, 7])); d2.update((r) => r.t.editByPath([1, 0, 0, 6], [1, 0, 0, 6], { type: 'text', value: '5', }), ); await c2.sync(); await c1.sync(); const eventCollector = new EventCollector<{ type: DocEventType }>(); const unsub = d2.subscribe((event) => { const { fromPath, toPath } = event.value.operations[0]; console.log(event.value.operations[0]); assert.deepEqual(fromPath, [1, 0, 0, 4]); // fromPath should be [1,0,0,7] (same as in the remote change) assert.deepEqual(toPath, [1, 0, 0, 8]); eventCollector.add({ type: event.type }); }); d2.update((r) => r.t.editByPath([1, 0, 0, 7], [1, 0, 0, 8])); await c2.sync(); await c1.sync(); assert.equal( d1.getRoot().t.toXML(), /*html*/ `<r><c><u><p><n></n></p></u></c><c><p><n>1abcd45gh23</n></p></c></r>`, ); assert.equal( d2.getRoot().t.toXML(), /*html*/ `<r><c><u><p><n></n></p></u></c><c><p><n>1abcd45gh23</n></p></c></r>`, ); await eventCollector.waitAndVerifyNthEvent(1, { type: DocEventType.LocalChange, }); }, task.name); });
What you expected to happen:
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
yorkie version
The text was updated successfully, but these errors were encountered:
indexTree.treePosToPath
No branches or pull requests
What happened:
When performing a
tree.edit
operation, thefromPath
andtoPath
values in document event are sometimes calculated incorrectly.To reproduce the issue, you can run the following test code:
What you expected to happen:
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
yorkie version
):The text was updated successfully, but these errors were encountered: