From dfacffdcb198497080f2f1f54cd5e9744ca94510 Mon Sep 17 00:00:00 2001 From: Clouds Date: Mon, 31 May 2021 15:50:30 +0800 Subject: [PATCH 1/2] Split by lines when parsing stdout of build --- src/arduino/arduino.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/arduino/arduino.ts b/src/arduino/arduino.ts index 785df236..5f377183 100644 --- a/src/arduino/arduino.ts +++ b/src/arduino/arduino.ts @@ -725,9 +725,14 @@ export class ArduinoApp { } return ret; } + let stdoutbuf = "" const stdoutcb = (line: string) => { if (cocopa.callback) { - cocopa.callback(line); + stdoutbuf += line + let lines = [stdoutbuf]; + lines = stdoutbuf.split('\n'); + stdoutbuf = lines.pop()!; + lines.forEach((line) => cocopa.callback(line)); } if (verbose) { arduinoChannel.channel.append(line); From 9fe4414b5d563002affec8b7ff12e8a2005b2f09 Mon Sep 17 00:00:00 2001 From: Clouds Date: Mon, 31 May 2021 15:59:03 +0800 Subject: [PATCH 2/2] cleanup --- src/arduino/arduino.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/arduino/arduino.ts b/src/arduino/arduino.ts index 5f377183..2d9c3717 100644 --- a/src/arduino/arduino.ts +++ b/src/arduino/arduino.ts @@ -725,12 +725,11 @@ export class ArduinoApp { } return ret; } - let stdoutbuf = "" + let stdoutbuf = ""; const stdoutcb = (line: string) => { if (cocopa.callback) { - stdoutbuf += line - let lines = [stdoutbuf]; - lines = stdoutbuf.split('\n'); + stdoutbuf += line; + let lines = stdoutbuf.split('\n'); stdoutbuf = lines.pop()!; lines.forEach((line) => cocopa.callback(line)); }