diff --git a/src/utils/encoding.js b/src/utils/encoding.js index 2ba23408..3506c05b 100644 --- a/src/utils/encoding.js +++ b/src/utils/encoding.js @@ -380,6 +380,8 @@ export const writeStructsFromTransaction = (encoder, transaction) => writeClient */ export const readUpdateV2 = (decoder, ydoc, transactionOrigin, structDecoder = new UpdateDecoderV2(decoder)) => transact(ydoc, transaction => { + // force that transaction.local is set to non-local + transaction.local = false let retry = false const doc = transaction.doc const store = doc.store diff --git a/tests/y-text.tests.js b/tests/y-text.tests.js index fa325750..8a900da5 100644 --- a/tests/y-text.tests.js +++ b/tests/y-text.tests.js @@ -455,6 +455,44 @@ export const testSplitSurrogateCharacter = tc => { } } +/** + * Search marker bug https://github.com/yjs/yjs/issues/307 + * + * @param {t.TestCase} tc + */ +export const testSearchMarkerBug1 = tc => { + const { users, text0, text1, testConnector } = init(tc, { users: 2 }) + + users[0].on('update', update => { + users[0].transact(() => { + Y.applyUpdate(users[0], update) + }) + }) + users[0].on('update', update => { + users[1].transact(() => { + Y.applyUpdate(users[1], update) + }) + }) + + text0.insert(0, 'a_a') + testConnector.flushAllMessages() + text0.insert(2, 's') + testConnector.flushAllMessages() + text1.insert(3, 'd') + testConnector.flushAllMessages() + text0.delete(0, 5) + testConnector.flushAllMessages() + text0.insert(0, 'a_a') + testConnector.flushAllMessages() + text0.insert(2, 's') + testConnector.flushAllMessages() + text1.insert(3, 'd') + testConnector.flushAllMessages() + t.compareStrings(text0.toString(), text1.toString()) + t.compareStrings(text0.toString(), 'a_sda') + compare(users) +} + // RANDOM TESTS let charCounter = 0