Skip to content

"Go to Definition" results in duplicate tabs when target is in sketch created in previous IDE version #1054

Closed
@per1234

Description

@per1234

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

  1. Start Arduino IDE 2.0.0-rc6.
  2. Select File > New from the Arduino IDE menus.
  3. Create a sketch that contains a function definition and a call to that function:
    void setup() {
      foo();
    }
    void loop() {}
    void foo() {}
  4. Save the sketch to any convenient name and location.
  5. Select File > Quit from the Arduino IDE menus.
  6. Start the latest version of the Arduino IDE.
  7. Open the sketch you created if it is not already.
  8. Select any board with language server support (e.g., Arduino Uno) from the Tools > Board menu in the Arduino IDE.
  9. Select the editor.
  10. Right click on the function call:
    foo();
  11. 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.

image

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:


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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions