A bug for grammar auto checking IDE 2.0. beta 7

If there is an header file problem.
The rest of code will display with unknown errors.
such as "Serial.begin(9600)" will be underlined with a "red wave line".

Even after fixed the header file problem, the "red wave lines" can not be removed automatically.
I have to close the sketch and reopen it then the "red wave lines" will go away.

Is that a bug or I did it wrong?

Please post an example of code that exhibits this problem

I was running this code from online. First I didn't have library "Arduino_APDS9960" installed, so that there were grammar errors everywhere.
After I installed the library, the red wave lines still in the files, I have to reopen the sketch in order to display in right format.
/*

Object color sampler


Samples the color of objects and outputs CSV logfile to serial console

Hardware: Arduino Nano 33 BLE Sense board.

Usage: Place object of interest to the color sensor

This example code is in the public domain.

*/

#include <Arduino_APDS9960.h>

void setup() {

Serial.begin(9600);

while (!Serial) {};

if (!APDS.begin()) {

Serial.println("Error initializing APDS9960 sensor.");

}

// print the header

Serial.println("Red,Green,Blue");

}

void loop() {

int r, g, b, c, p;

float sum;

// wait for proximity and color sensor data

while (!APDS.colorAvailable() || !APDS.proximityAvailable()) {}

// read the color and proximity data

APDS.readColor(r, g, b, c);

sum = r + g + b;

p = APDS.readProximity();

// if object is close and well enough illumated

if (p == 0 && c > 10 && sum > 0) {

float redRatio = r / sum;

float greenRatio = g / sum;

float blueRatio = b / sum;

// print the data in CSV format

Serial.print(redRatio, 3);

Serial.print(',');

Serial.print(greenRatio, 3);

Serial.print(',');

Serial.print(blueRatio, 3);

Serial.println();

}

}

Why do users choose to ignore the advice on posting code ?

The easier you make it to read and copy your code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.