From 7c86f1f9d31f199958e78c10063e0245c7a6af2b Mon Sep 17 00:00:00 2001 From: Frank Palazzolo Date: Tue, 13 Dec 2022 03:01:51 -0500 Subject: [PATCH] Fix corruption of incoming UTF-8-encoded serial data (#1758) * Fix corruption of incoming UTF-8-encoded serial data * Make TextDecoder() readonly because it can be Co-authored-by: z3bra <111462146+z3bra5hax@users.noreply.github.com> --- arduino-ide-extension/src/node/monitor-service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arduino-ide-extension/src/node/monitor-service.ts b/arduino-ide-extension/src/node/monitor-service.ts index fca3c748..db5f100d 100644 --- a/arduino-ide-extension/src/node/monitor-service.ts +++ b/arduino-ide-extension/src/node/monitor-service.ts @@ -80,6 +80,7 @@ export class MonitorService extends CoreClientAware implements Disposable { private readonly board: Board; private readonly port: Port; private readonly monitorID: string; + private readonly streamingTextDecoder = new TextDecoder('utf8'); /** * The lightweight representation of the port configuration currently in use for the running monitor. @@ -319,7 +320,7 @@ export class MonitorService extends CoreClientAware implements Disposable { const message = typeof data === 'string' ? data - : new TextDecoder('utf8').decode(data); + : this.streamingTextDecoder.decode(data, {stream:true}); this.messages.push(...splitLines(message)); }, },