Description
Describe the problem
The Arduino IDE's language server-based "Go to definition" feature reveals the definition of a code component. If that definition is in a file that is not already open in an editor tab, a tab must be added for that file. If the file is already open in a tab then that tab is simply selected and the cursor placed at the start of the definition.
🐛 If the sketch was created in an earlier version of the Arduino IDE, "Go to definition" for a definition within one of the open sketch editor tabs causes the creation of a confusing duplicate tab instead of simply using the existing tab.
To reproduce
- Start Arduino IDE 2.0.0-rc6.
- Select File > New from the Arduino IDE menus.
- Create a sketch that contains a function definition and a call to that function:
void setup() { foo(); } void loop() {} void foo() {}
- Save the sketch to any convenient name and location.
- Select File > Quit from the Arduino IDE menus.
- Start the latest version of the Arduino IDE.
- Open the sketch you created if it is not already.
- Select any board with language server support (e.g., Arduino Uno) from the Tools > Board menu in the Arduino IDE.
- Select the editor.
- Right click on the function call:
foo();
- Select "Go to Definition" from the context menu.
🐛 A duplicate tab is created.
🐛 The cursor is only moved to the start of the function definition in the newly created tab, and that tab is not selected, so the user is not guided to the function definition in any meaningful way.
Expected behavior
Duplicate tabs are not created.
Arduino IDE version
2.0.0-rc7
Operating system
Windows
Operating system version
Windows 10
Additional context
Related:
- IDE starts unexpectedly; sketch is not set as workspace root, menu items are missing #1044
- Editor manager should be singleton, patched layout restorer to avoid duplicate editor tabs #1024
- Selecting sketch file with double-click results in duplicate tabs #656
- Selecting sketch tab via menu results in duplicate tabs #793
Originally reported at https://forum.arduino.cc/t/ctrl-click-navigation/1000117/19
Issue checklist
- I searched for previous reports in the issue tracker
- I verified the problem still occurs when using the latest nightly build
- My report contains all necessary details