Skip to content

Commit 9a95532

Browse files
authored
Merge pull request microsoft#1591 from microsoft/dev/bemcmorr/arduino-cli-intellisense
Fix IntelliSense configuration for Arduino CLI
2 parents 8555430 + c0b6f47 commit 9a95532

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/arduino/arduino.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ export class ArduinoApp {
656656

657657
// We always build verbosely but filter the output based on the settings
658658

659-
this._settings.useArduinoCli ? args.push("--verbose") : args.push("--verbose-build");
659+
this._settings.useArduinoCli ? args.push("--verbose", "--no-color") : args.push("--verbose-build");
660660

661661
if (verbose && !this._settings.useArduinoCli) {
662662
args.push("--verbose-upload");
@@ -757,16 +757,17 @@ export class ArduinoApp {
757757
const wrapLineCallback = (callback: (line: string) => void) => {
758758
let buffer = "";
759759
let startIndex = 0;
760+
const eol = this.useArduinoCli() ? "\n" : os.EOL;
760761
return (data: string) => {
761762
buffer += data;
762763
while (true) {
763-
const pos = buffer.indexOf(os.EOL, startIndex);
764+
const pos = buffer.indexOf(eol, startIndex);
764765
if (pos < 0) {
765766
startIndex = buffer.length;
766767
break;
767768
}
768-
const line = buffer.substring(0, pos + os.EOL.length);
769-
buffer = buffer.substring(pos + os.EOL.length);
769+
const line = buffer.substring(0, pos + eol.length);
770+
buffer = buffer.substring(pos + eol.length);
770771
startIndex = 0;
771772
callback(line);
772773
}

src/common/util.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,11 @@ export function spawn(
246246
}
247247

248248
child.on("error", (error) => reject({ error }));
249-
child.on("exit", (code) => {
249+
250+
// It's important to use use the "close" event instead of "exit" here.
251+
// There could still be buffered data in stdout or stderr when the
252+
// process exits that we haven't received yet.
253+
child.on("close", (code) => {
250254
if (code === 0) {
251255
resolve({ code });
252256
} else {

0 commit comments

Comments
 (0)