Przeglądaj źródła

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

Paulus Schoutsen 2 lat temu
rodzic
commit
de749bd83e
1 zmienionych plików z 6 dodań i 5 usunięć
  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));
     addSpan(line.substring(i));
 
 
-    if (
+    // Keep scroll at bottom
-      this.targetElement.scrollTop + 56 >=
+    if (atBottom) {
-      this.targetElement.scrollHeight - this.targetElement.offsetHeight
-    ) {
-      // at bottom
       this.targetElement.scrollTop = this.targetElement.scrollHeight;
       this.targetElement.scrollTop = this.targetElement.scrollHeight;
     }
     }
   }
   }