Hi, I'm looking for the option to show only highlighted lines in the affected sketch in case of compile errors. In case of a large sketch you have to scroll a lot to find them all. Or is there a command available to quickly jump to the next highlighted line(s)?
Not quite what you're looking for but in the IDE you can use <CTRL>L to go to a line. As the error message contains the line number, it will be a reasonable alternative.
Keyboard Shortcuts shows both
- Go to Next Problem (Error, Warning, Info)
- Go to Next Problem in Files (Error, Warning, Info)
with keybindings, which take effect When: editorFocus. I compiled
void setup() {
// put your setup code here, to run once:
x = 7
}
void loop() {
// put your main code here, to run repeatedly:
y = 2
}
The two lines with errors are highlighted, but neither keystroke did anything, nor did selecting the command from the Command Palette.
Maybe those do something else? (Dunno what "in Files" means. There's also Go to Next Difference when isInDiffEditor -- is there a diff editor?)
This is because 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.
Hi @hwilly.
There are a couple of relevant features in Arduino IDE 2.x:
Reveal Error
- Hover the mouse pointer over the
<path>:<line number>:<column number>reference in an error.
A tooltip will appear. - Click the "Reveal Error" link in the tooltip.
The editor cursor will be moved to the referenced point in the code.
If you are using the feature frequently, you will find it more efficient to use the keyboard shortcut (e.g., Ctrl+click) that is shown in the tooltip instead of hovering.
Error Navigation
Arduino IDE 2.x also has an "experimental" feature that adds an annotation to each of the error lines, allowing you to navigate from one to the next.
Enable Feature
The feature must be enabled in Arduino IDE's advanced settings:
- 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 command name in the field.
A "Settings" tab will open in the Arduino IDE main panel. - Type
arduino.compile.experimentalin the "Search Settings" field of the "Settings" tab. - Check the box under the "Arduino › Compile: Experimental" setting.
- Close the Preferences tab by clicking its X icon.
Feature Usage
- Compile a sketch that produces a compilation error.
The editor cursor will be automatically moved to the point of the first error encountered by the compiler. - You will see an annotation above that line in the editor:
Previous Error | Next Error
- Click the "Previous Error" or "Next Error" link in the line annotation.
The editor cursor will be moved to the point of the next compiler error in the sketch.
Hi @ptillisch, many thanks for the exact solution. I just applied and it works as I expected! Additional I learned about advanced settings. That's a valuable goody.
You are welcome. I'm glad if I was able to be of assistance.
Regards, Per
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
