From 5eb6dff039333e42c02713575f228eba98569f14 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Sun, 7 Aug 2022 22:21:13 -0700 Subject: [PATCH] Fix terminal glitch on error. --- web/platform.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/platform.fs b/web/platform.fs index 6eee11e..7f1a18e 100644 --- a/web/platform.fs +++ b/web/platform.fs @@ -64,10 +64,10 @@ if (!globalObj.write) { context.ctx = context.canvas.getContext('2d'); context.AddLine = function() { - if (context.outbuffer.length > 0) { + if (context.last_line) { context.Update(true); - context.outbuffer = []; } + context.outbuffer = []; var line = document.createElement('pre'); line.style.width = '100%'; line.style.whiteSpace = 'pre-wrap'; @@ -91,7 +91,6 @@ if (!globalObj.write) { context.outbuffer = []; context.AddLine(); }; - context.ResetTerminal(); context.keyboard = document.createElement('div'); context.KEY_HEIGHT = 45; @@ -285,6 +284,7 @@ if (!globalObj.write) { context.last_line.innerText = new TextDecoder('utf-8').decode( new Uint8Array(context.outbuffer)) + (newline ? '' : cursor); }; + context.ResetTerminal(); window.addEventListener('paste', function(e) { context.Inject(e.clipboardData.getData('text')); });