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>
This commit is contained in:
Frank Palazzolo 2022-12-13 03:01:51 -05:00 committed by GitHub
parent f8c01e379c
commit 7c86f1f9d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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