I routinely copy code from the forum into a sketch that I already have open in the IDE having first deleted the text of the existing sketch
However, this does not cause the function and variable index to be rebuilt which means that the definitions cannot be opened. Moreover, the original definitions seem to be referenced. See screenshots below
Even funnier is this which pops up when I put the cursor over the println() function
Is there a keyboard shortcut to force a rebuild of the function and variable indices for the current sketch ?
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 "Arduino: Restart Language Server" 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.
Unfortunately it looks like there isn't a way to assign a keyboard shortcut to this action. The IDE does remember which commands you selected previously from the command palette, so the "Arduino: Restart Language Server" command will be at the top of the menu after the first time you use it.
Thanks Per. That looks hopeful and it does result in the "indexing" message bottom left of the IDE. However, the definitions are still not available afterwards
That is unfortunate. I tried to reproduce the fault, but it is working as expected for me, even without needing to trigger the "Arduino: Restart Language Server" command. When I paste a new sketch into the Arduino IDE editor, it triggers the "Building sketch" operation.
Please provide instructions I can follow to reproduce it.
Make sure to include the following information:
The previous sketch code to be replaced
The replacement sketch code
Which board you have selected from the Tools > Board menu in Arduino IDE