Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7e4724edd | ||
|
|
71d8da6513 | ||
|
|
c72ac448e9 | ||
|
|
da21fca334 | ||
|
|
d80512d690 | ||
|
|
6886881b76 |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.5.6",
|
"version": "13.5.9",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "yjs",
|
"name": "yjs",
|
||||||
"version": "13.5.6",
|
"version": "13.5.9",
|
||||||
"description": "Shared Editing Library",
|
"description": "Shared Editing Library",
|
||||||
"main": "./dist/yjs.cjs",
|
"main": "./dist/yjs.cjs",
|
||||||
"module": "./dist/yjs.mjs",
|
"module": "./dist/yjs.mjs",
|
||||||
|
|||||||
@@ -566,6 +566,19 @@ export class Item extends AbstractStruct {
|
|||||||
this.content.constructor === right.content.constructor &&
|
this.content.constructor === right.content.constructor &&
|
||||||
this.content.mergeWith(right.content)
|
this.content.mergeWith(right.content)
|
||||||
) {
|
) {
|
||||||
|
const searchMarker = /** @type {AbstractType<any>} */ (this.parent)._searchMarker
|
||||||
|
if (searchMarker) {
|
||||||
|
searchMarker.forEach(marker => {
|
||||||
|
if (marker.p === right) {
|
||||||
|
// right is going to be "forgotten" so we need to update the marker
|
||||||
|
marker.p = this
|
||||||
|
// adjust marker index
|
||||||
|
if (!this.deleted && this.countable) {
|
||||||
|
marker.index -= this.length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
if (right.keep) {
|
if (right.keep) {
|
||||||
this.keep = true
|
this.keep = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -380,6 +380,8 @@ export const writeStructsFromTransaction = (encoder, transaction) => writeClient
|
|||||||
*/
|
*/
|
||||||
export const readUpdateV2 = (decoder, ydoc, transactionOrigin, structDecoder = new UpdateDecoderV2(decoder)) =>
|
export const readUpdateV2 = (decoder, ydoc, transactionOrigin, structDecoder = new UpdateDecoderV2(decoder)) =>
|
||||||
transact(ydoc, transaction => {
|
transact(ydoc, transaction => {
|
||||||
|
// force that transaction.local is set to non-local
|
||||||
|
transaction.local = false
|
||||||
let retry = false
|
let retry = false
|
||||||
const doc = transaction.doc
|
const doc = transaction.doc
|
||||||
const store = doc.store
|
const store = doc.store
|
||||||
|
|||||||
@@ -32,6 +32,35 @@ export const testSlice = tc => {
|
|||||||
t.compareArrays(arr.slice(0, 2), [0, 1])
|
t.compareArrays(arr.slice(0, 2), [0, 1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Debugging yjs#297 - a critical bug connected to the search-marker approach
|
||||||
|
*
|
||||||
|
* @param {t.TestCase} tc
|
||||||
|
*/
|
||||||
|
export const testLengthIssue = tc => {
|
||||||
|
const doc1 = new Y.Doc()
|
||||||
|
const arr = doc1.getArray('array')
|
||||||
|
arr.push([0, 1, 2, 3])
|
||||||
|
arr.delete(0)
|
||||||
|
arr.insert(0, [0])
|
||||||
|
t.assert(arr.length === arr.toArray().length)
|
||||||
|
doc1.transact(() => {
|
||||||
|
arr.delete(1)
|
||||||
|
t.assert(arr.length === arr.toArray().length)
|
||||||
|
arr.insert(1, [1])
|
||||||
|
t.assert(arr.length === arr.toArray().length)
|
||||||
|
arr.delete(2)
|
||||||
|
t.assert(arr.length === arr.toArray().length)
|
||||||
|
arr.insert(2, [2])
|
||||||
|
t.assert(arr.length === arr.toArray().length)
|
||||||
|
})
|
||||||
|
t.assert(arr.length === arr.toArray().length)
|
||||||
|
arr.delete(1)
|
||||||
|
t.assert(arr.length === arr.toArray().length)
|
||||||
|
arr.insert(1, [1])
|
||||||
|
t.assert(arr.length === arr.toArray().length)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {t.TestCase} tc
|
* @param {t.TestCase} tc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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
|
// RANDOM TESTS
|
||||||
|
|
||||||
let charCounter = 0
|
let charCounter = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user