Skip to content

Commit d8ca3a6

Browse files
webzwo0irhansen
authored andcommitted
timeslider scrollTo: fixes wrong line number calculation in case there
are no attribute changes and no length changes
1 parent 9bad1d0 commit d8ca3a6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/static/js/broadcast.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,16 @@ const loadBroadcastJS = (socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
164164
return true; // break
165165
}
166166
});
167-
// deal with someone is the author of a line and changes one character,
168-
// so the alines won't change
167+
// some chars are replaced (no attributes change and no length change)
168+
// test if there are keep ops at the start of the cs
169169
if (lineChanged === undefined) {
170-
lineChanged = Changeset.opIterator(Changeset.unpack(changeset).ops).next().lines;
170+
lineChanged = 0;
171+
const opIter = Changeset.opIterator(Changeset.unpack(changeset).ops);
172+
173+
if (opIter.hasNext()) {
174+
const op = opIter.next();
175+
if (op.opcode === '=') lineChanged += op.lines;
176+
}
171177
}
172178

173179
const goToLineNumber = (lineNumber) => {

0 commit comments

Comments
 (0)