From d8ca3a693d08f68044cdd08f1bab7f706f75cfdc Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Fri, 29 Oct 2021 00:12:47 +0200 Subject: [PATCH] timeslider scrollTo: fixes wrong line number calculation in case there are no attribute changes and no length changes --- src/static/js/broadcast.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/static/js/broadcast.js b/src/static/js/broadcast.js index 909b6a085..6ba2ef0ab 100644 --- a/src/static/js/broadcast.js +++ b/src/static/js/broadcast.js @@ -164,10 +164,16 @@ const loadBroadcastJS = (socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro return true; // break } }); - // deal with someone is the author of a line and changes one character, - // so the alines won't change + // some chars are replaced (no attributes change and no length change) + // test if there are keep ops at the start of the cs if (lineChanged === undefined) { - lineChanged = Changeset.opIterator(Changeset.unpack(changeset).ops).next().lines; + lineChanged = 0; + const opIter = Changeset.opIterator(Changeset.unpack(changeset).ops); + + if (opIter.hasNext()) { + const op = opIter.next(); + if (op.opcode === '=') lineChanged += op.lines; + } } const goToLineNumber = (lineNumber) => {