Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
per1234 opened this issue Jun 13, 2022 · 2 comments · Fixed by #1085
Closed
3 tasks done
Assignees
Labels
conclusion: resolved Issue was resolved criticality: high Of high impact topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Jun 13, 2022

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
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Jun 13, 2022
@ubidefeo ubidefeo added the criticality: high Of high impact label Jun 13, 2022
@per1234 per1234 mentioned this issue Jun 14, 2022
3 tasks
@kittaakos
Copy link
Contributor

Crazy, but this is the problem: when opening an editor, all widget open options must be the same. See here.

(Since editor widget identity is based not only on the URI, but also the options, we need to pass the correct options into the open call. Doing that prevents Theia from opening multiple tabs of the same editor)

It means, when opening /path/to/resource/MySketch/MySketch.ino file in the editor, the uri, the counter, kind, .etc must be the same.

But the order of the properties also matters 🤦

This is the known, opened editor widget in the widget manager:

{
    "factoryId": "code-editor-opener",
    "options": {
        "uri": "file:///Users/a.kitta/Documents/Arduino/xxx2/xxx2.ino",
        "kind": "navigatable",
        "counter": 0
    }
}

This is the editor IDE2 wants to open with Go to Definition:

{
    "factoryId": "code-editor-opener",
    "options": {
        "kind": "navigatable",
        "uri": "file:///Users/a.kitta/Documents/Arduino/xxx2/xxx2.ino",
        "counter": 0
    }
}

The two objects are deeply equal, but they're not the same. Here is the corresponding code in Theia.

@kittaakos
Copy link
Contributor

I can confirm that I could reproduce similar defect with vanilla Theia: eclipse-theia/theia#11309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved criticality: high Of high impact topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants