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

pull/4409/head
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
1 changed files with 8 additions and 2 deletions

View File

@ -255,9 +255,15 @@ 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")){
goToLineNumber(lineNumber);
if(padContents.currentLines.length <= lineNumber){
goToLineNumber(padContents.currentLines.length-1)
} else {
goToLineNumber(lineNumber);
}
}
Changeset.mutateTextLines(changeset, padContents);