Fix console not staying at bottom if new line spanned two lines (#302)

This commit is contained in:
Paulus Schoutsen 2023-01-02 21:39:45 -05:00 committed by GitHub
parent 98891ab73f
commit de749bd83e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -178,13 +178,14 @@ export class ColoredConsole {
}
}
}
const atBottom =
this.targetElement.scrollTop >
this.targetElement.scrollHeight - this.targetElement.offsetHeight - 50;
addSpan(line.substring(i));
if (
this.targetElement.scrollTop + 56 >=
this.targetElement.scrollHeight - this.targetElement.offsetHeight
) {
// at bottom
// Keep scroll at bottom
if (atBottom) {
this.targetElement.scrollTop = this.targetElement.scrollHeight;
}
}