fix: invalid custom board option handling in FQBN

Closes arduino/arduino-ide#1588

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta
2024-02-08 16:30:09 +01:00
committed by Akos Kitta
parent 2a325a5b74
commit a088ba99f5
11 changed files with 586 additions and 139 deletions

View File

@@ -267,24 +267,12 @@ export class BoardDiscovery
const { port, boards } = detectedPort;
const key = Port.keyOf(port);
if (eventType === EventType.Add) {
const alreadyDetectedPort = newState[key];
if (alreadyDetectedPort) {
console.warn(
`Detected a new port that has been already discovered. The old value will be overridden. Old value: ${JSON.stringify(
alreadyDetectedPort
)}, new value: ${JSON.stringify(detectedPort)}`
);
}
// Note that, the serial discovery might detect port details (such as addressLabel) in chunks.
// For example, first, the Teensy 4.1 port is detected with the `[no_device] Triple Serial` address label,
// Then, when more refinements are available, the same port is detected with `/dev/cu.usbmodem127902301 Triple Serial` address label.
// In such cases, an `add` event is received from the CLI, and the the detected port is overridden in the state.
newState[key] = { port, boards };
} else if (eventType === EventType.Remove) {
const alreadyDetectedPort = newState[key];
if (!alreadyDetectedPort) {
console.warn(
`Detected a port removal but it has not been discovered. This is most likely a bug! Detected port was: ${JSON.stringify(
detectedPort
)}`
);
}
delete newState[key];
}
}