timeslider: bugfix: follow pad contents - only goToLineNumber if it exists (#4390)

This commit is contained in:
webzwo0i 2020-10-10 17:57:22 +02:00 committed by GitHub
parent 048bd0f50d
commit a2328cd7f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -255,10 +255,16 @@ function loadBroadcastJS(socket, sendSocketMsg, fireWhenAllScriptsAreLoaded, Bro
debugLog(e);
}
var lineNumber = Changeset.opIterator(Changeset.unpack(changeset).ops).next().lines;
// we want to scroll to the area that is changed before the lines are mutated and we can't go
// to a line that is not there yet
let lineNumber = Changeset.opIterator(Changeset.unpack(changeset).ops).next().lines;
if($('#options-followContents').is(":checked") || $('#options-followContents').prop("checked")){
if(padContents.currentLines.length <= lineNumber){
goToLineNumber(padContents.currentLines.length-1)
} else {
goToLineNumber(lineNumber);
}
}
Changeset.mutateTextLines(changeset, padContents);
padContents.currentRevision = revision;