From 38eb2e502c6f7d7a21495113c7180f4dba4df93d Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Thu, 16 Jul 2020 20:44:54 +0200 Subject: [PATCH] stricter searchMarker filter --- src/types/AbstractType.js | 5 +++-- tests/y-text.tests.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/types/AbstractType.js b/src/types/AbstractType.js index 1f414fec..99f981ad 100644 --- a/src/types/AbstractType.js +++ b/src/types/AbstractType.js @@ -19,7 +19,7 @@ import * as iterator from 'lib0/iterator.js' import * as error from 'lib0/error.js' import * as math from 'lib0/math.js' -const maxSearchMarker = 60 +const maxSearchMarker = 80 /** * A unique timestamp that identifies each marker. @@ -152,11 +152,12 @@ export const findMarker = (yarray, index) => { // if (marker) { // if (window.lengthes == null) { // window.lengthes = [] + // window.getLengthes = () => window.lengthes.sort((a, b) => a - b) // } // window.lengthes.push(marker.index - pindex) // console.log('distance', marker.index - pindex, 'len', p && p.parent.length) // } - if (marker !== null && math.abs(marker.index - pindex) < 30) { + if (marker !== null && math.abs(marker.index - pindex) < p.parent.length / maxSearchMarker) { // adjust existing marker overwriteMarker(marker, p, pindex) return marker diff --git a/tests/y-text.tests.js b/tests/y-text.tests.js index 396e2a13..b4440e5f 100644 --- a/tests/y-text.tests.js +++ b/tests/y-text.tests.js @@ -209,7 +209,7 @@ export const testFormattingRemovedInMidText = tc => { * @param {t.TestCase} tc */ export const testInsertAndDeleteAtRandomPositions = tc => { - const N = 10000 + const N = 100000 const { text0 } = init(tc, { users: 1 }) const gen = tc.prng