Open UKHeliBob opened 3 years ago
@UKHeliBob please follow the issue report template in order to keep all information centralised. This helps us track issues much better without a back-and-forth between GH and Forum
thanks
To Reproduce Following the instructions from https://www.arduino.cc/en/Tutorial/getting-started-with-ide-v2/ide-v2-autocomplete-feature/ I cannot make Autocomplete work as described
With a new sketch loaded and Arduino Nano selected as the board type, typing pin brings up an autocomplete suggestions list with pinMode at the top, and clicking on that or pressing return selects it. uint8_t pin is automatically selected as described,
Expected behaviour Typing LED at that point should bring up the suggestion of LED_BUILTIN but it does not
Desktop Environment Windows 10 IDE version 2.0.0-Beta 3
Additional context See https://forum.arduino.cc/index.php?topic=731873
thanks @UKHeliBob Sometimes macros get lost for some targets, even though similar targets with same CPU/specs find and suggest the expansion. Language Server is still quite glitchy, but it is in constant development and refinement so I'm sure we'll nail this kind of issue as we move forward ✌🏼
I'm also having this problem. The autocomplete shows up if I press ctrl+space, but not automatically. I think there might be a setting to trigger the autocomplete on more characters but I can't find it.
The autocomplete shows up if I press ctrl+space, but not automatically.
I think this comment is the key to understanding the issue.
I was having trouble reproducing it because I always have File > Preferences > Editor Quick Suggestions disabled and so I instinctively use the "Trigger Suggest" keyboard shortcut (e.g., Ctrl+Space) to trigger the autocomplete suggestions.
The tutorial was written before the "Editor Quick Suggestions" was changed to being off by default (https://github.com/arduino/arduino-ide/pull/221), so it assumes the feature is on. After enabling the feature, I get the expected quick suggestion for pinMode
, but not for LED_BUILTIN
argument (even while using the build from https://github.com/arduino/arduino-ide/pull/610 with the revamped language server). But this behavior is specific to the argument autocomplete process. If I type "LED" as an argument while not in an autocomplete operation, then I get the LED_BUILTIN
quick suggestion as expected.
It also isn't specific to macros. For example, you won't get a quick suggestion for random
in the argument while autocompleting delay(random(1000));
This issue has two components:
This was resolved 2021-12-07 (before the tutorial was published to the public repository) by the addition of an "Enable/Disable Autocompletion" section to the tutorial:
The tutorial instructions were later changed to mostly use the Ctrl+Space "Trigger Suggest" keyboard shortcut, making them applicable even for users with "Editor Quick Suggestions" disabled in their preferences: https://github.com/arduino/docs-content/pull/427
This was resolved by https://github.com/arduino/docs-content/pull/427
Since it is maybe a little more difficult to reproduce now that following the tutorial doesn't result in this behavior, I'll provide complete instructions to reproduce it:
void foo(int bar, int baz) {}
const int pippo = 42;
void setup() {
foo(pipp, int baz)
}
void loop() {}
ⓘ The code is different from that in the tutorial only to provide a self contained demo that doesn't rely on code from the core of the selected board. The pinMode
code from the tutorial will also produce the issue though.
setup
function definition block, type the following text:
fo
foo(int bar, int baz)
The int bar
argument will be automatically selected.
pipp
foo
function call in the Arduino IDE editor.
The gray highlights on the function call arguments disappear.pipp
again in the first argument of the foo
function call.Since I don't ever use code completion, I'm no expert on how the Suggest feature is expected to work, but this behavior seems quite inconsistent and annoying to me. However, I see that it also occurs when I do the same procedure with a pure C++ program in VS Code with the clangd extension installed. So maybe it is the expected and correct behavior? In that case, we could close this as resolved by the tutorial changes I mentioned above.
I didn't find a setting that allows this behavior to be adjusted.
I have a similar issue, may be related to this? https://forum.arduino.cc/t/solved-auto-completion-not-working-on-arduino-2-1/1120524
A bug in arduino-cli was mentioned in post #5.
The solution described there was to move all the sketched to C: drive. That did not work for me. I'm not sure if the Arduino IDE itself needs to be installed on C: drive on windows.
For me function completion is missing. if I type mil
and press Ctrl+Space
, I expect it to suggest millis()
and with all the param hints/overloads/etc if any in the popup
The weird part it was working a few days ago. The only change is that I had a previous install of Arduino IDE 1.8 installed at the same time. I did some cleanup and removed all Arduino related software and reinstalled only IDE 2.1.1 and libraries for it.
So a solution presented itself now that I took 2 minutes to think about it.
I downloaded the latest release of arduino-cli:0.33.1
and replaced the arduino-cli.exe
under resources\app\node_modules\arduino-ide-extension\build
. Quick suggestions now work as expected.
Seems that CLI 0.33.1 will be bundled with IDE 2.1.2, so if sketches are stored on a different drive than C:, that problem will resolved itself. Not sure if the exact same problem as @UKHeliBob though.
Following the instructions from https://www.arduino.cc/en/Tutorial/getting-started-with-ide-v2/ide-v2-autocomplete-feature/ I cannot make Autocomplete work as described
With a new sketch loaded and Arduino Nano selected as the board type, typing pin as suggested brings up an autocomplete suggestions list with pinMode at the top, and clicking on that or pressing return selects it. uint8_t pin is automatically selected as described, but typing but typing LED does not bring up the suggestion of LED_BUILTIN as described. Typing the name in full and hovering over it does show the fact that it is a macro with a value of 13 and right clicking and selecting Go to Definition opens pins_arduino.h showing how the macro is defined so it is obviously known to the editor
See https://forum.arduino.cc/index.php?topic=731873