Prechádzať zdrojové kódy

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

Paulus Schoutsen 2 rokov pred
rodič
commit
de749bd83e
1 zmenil súbory, kde vykonal 6 pridanie a 5 odobranie
  1. 6 5
      src/util/console-color.ts

+ 6 - 5
src/util/console-color.ts

@@ -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;
     }
   }