You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current .update(targetStr) will calculate the difference based on the Myers diff. Although the computed difference has minimal edits, the difference can be very counterintuitive:
import{expect,it,describe,beforeEach}from'vitest';import{LoroDoc}from'loro-crdt';it('sync',()=>{constdocA=newLoroDoc();constdocB=newLoroDoc();docA.setPeerId(1);docB.setPeerId(0);docA.getText('text').update('Hello');docB.import(docA.export({mode: 'update',}));consttextA=docA.getText('text');textA.update('Oh, Hello World!\nThis sentence should stay untouched!');consttextB=docB.getText('text');textB.update('Hmmm, Hello Alice!');docA.import(docB.export({mode: 'update'}));docB.import(docA.export({mode: 'update'}));console.dir(docA.exportJsonUpdates(),{depth: 100});expect(docA.getText('text').toString()).toBe('Oh, Hmmm, Hello World! Alice!\nThis sentence should stay untouched!');// - Oh, Hmmm, Hello World! Alice!// + Oh, Hmmm, Hello World!// - This sentence should stay untouched!// + This sentence should stay unto Alice!uched!});
The current
.update(targetStr)
will calculate the difference based on the Myers diff. Although the computed difference has minimal edits, the difference can be very counterintuitive:https://stackblitz.com/edit/stackblitz-starters-2lf3ty?file=loro.test.js
The diagram of the cause of the issue:
The text was updated successfully, but these errors were encountered: