From 58214ccbeacd7ee44f57c17e3980a219aa2193c4 Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Fri, 28 Apr 2023 21:03:45 +0200 Subject: [PATCH] Fix: webapp console: Only add the date at the beginning if the last character was a newline --- webapp/src/views/ConsoleInfoView.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webapp/src/views/ConsoleInfoView.vue b/webapp/src/views/ConsoleInfoView.vue index 3ccf4cd..fb17f62 100644 --- a/webapp/src/views/ConsoleInfoView.vue +++ b/webapp/src/views/ConsoleInfoView.vue @@ -43,6 +43,7 @@ export default defineComponent({ dataLoading: true, consoleBuffer: "", isAutoScroll: true, + endWithNewline: false, }; }, created() { @@ -78,10 +79,13 @@ export default defineComponent({ console.log(event); let outstr = new String(event.data); + let removedNewline = false; if (outstr.endsWith('\n')) { outstr = outstr.substring(0, outstr.length - 1); + removedNewline = true; } - this.consoleBuffer += this.getOutDate() + outstr.replaceAll("\n", "\n" + this.getOutDate()); + this.consoleBuffer += (this.endWithNewline ? this.getOutDate() : '') + outstr.replaceAll("\n", "\n" + this.getOutDate()); + this.endWithNewline = removedNewline; this.heartCheck(); // Reset heartbeat detection };