How do I stop this from happening? Everytime I make a code change, it starts to build sketch and index for a few seconds till I can do anything else?
Hello @jackson92121 ,
What you're describing is the intended behavior of the IDE (especially in version 2.x): every time you make a change, the IDE performs a partial build and indexes your code in the background to provide features like autocomplete, real-time error checking, and code navigation.
Currently, there isn’t an option to disable this functionality, as it’s integrated to deliver an "intelligent" development experience. If this slowdown is too disruptive, you might consider:
- Using the classic (1.x) IDE: It doesn’t perform real-time indexing and can be more responsive.
- Waiting for future updates: The development team is aware of these performance issues and is working on optimizations for upcoming releases.
- Simone from Italy
Quite anoying, this constant building and indexing when altering code. I see no benefit regarding "autocomplete (what?), real-time error checking (how?), and code navigation (?)".
Seems that when compiling/uploading you have to save the changed code first, otherwise IDE takes the unchanged code.
Pls correct me if I am wrong.
You are wrong
Hi @rnieuwland.
You can learn about Arduino IDE 2.x's autocomplete feature from this tutorial:
https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-autocomplete-feature
The "problems" feature is disabled by default.
The reason it is disabled by default is that the system is prone to occasional spurious "problem" detections due to the fact that the "problems" data comes from the Arduino Language Server, not from the sketch compilation. During the beta testing phase of the Arduino IDE 2.x development when it was enabled by report, we received a significant number of reports from less experienced users who were alarmed and distracted by the appearance of these diagnostic markers. For this reason, the decision was made to disable the feature by default.
Some of these spurious detections are the result of corner case mismatches in behavior between the Clang C++ compiler used by the language server that produces the diagnostics and the GCC compiler that is used to compile the sketch programs. An even more significant cause of spurious detections is that, in order to reduce the processing resource usage of the Arduino IDE application, a deferred library discovery system is used. This means that, between the time you add a new library to a sketch and the first time you compile the sketch after that, all references to objects from that library will produce diagnostics due to the path to the library not yet having been added to the compiler's "search path".
It is possible to enable the "problems" feature via the Arduino IDE advanced settings. Even though it might not be suitable for a new user, a more experienced user has the ability to evaluate each of the problem detections and differentiate the legitimate ones from the spurious ones that should be ignored. I'll provide instruction you can follow to enable the feature:
- Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
A menu will appear on the editor toolbar:
- Select the "Preferences: Open Settings (UI)" command from the menu.
ⓘ You can scroll down through the list of commands to find it or type the name in the field.
A "Preferences" tab will open in the Arduino IDE main panel. - Type
arduino.language.realTimeDiagnosticsin the "Search Settings" field of the "Preferences" tab. - Check the box under the "Arduino › Language: Real Time Diagnostics" setting.
- Close the Preferences tab by clicking its X icon.
You will now find that a "squiggle" appears under each "problem" detected by the language server.
You can use the keyboard shortcuts you mentioned to navigate between them. You can also trigger those same commands via the "Command Palette". There is also a "Toggle Problems View" command that will open a list of all "problems" in the bottom panel of the Arduino IDE window. You can navigate by clicking the items in the list.
The most commonly used code navigation feature is "go to definition". This allows you to navigate from a reference to an object (e.g., a function call) in your code to the declaration/definition of that object. I'll provide instructions you can follow to do that:
- Right-click (Control-click for macOS users) on a reference to an object in the sketch.
A context menu will open. - Select "Go to Definition" from the menu.
The cursor will now move to the declaration or definition of the object. If that is in a different file, the file will open in an Arduino IDE editor tab.
This is often used to get some insight into code from a library or the core. In this case where the declaration/definition is located in an external file, you can close the newly added editor tab once you are done looking at it by clicking the X icon on the tab.
In case you prefer to see the declaration/definition inline, you can select Peek > Peek Definition from the context menu instead of "Go to Definition". This will cause the code to be displayed inside the current editor panel in a special "peek" interface.
Tx for your prompt reply! I'll look into that.
Regards Rob
Where did you get the idea in the first place ?
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
