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

"Open Recent" menu missing after recent sketch is deleted #1596

Closed
3 tasks done
per1234 opened this issue Oct 28, 2022 · 1 comment · Fixed by #1616
Closed
3 tasks done

"Open Recent" menu missing after recent sketch is deleted #1596

per1234 opened this issue Oct 28, 2022 · 1 comment · Fixed by #1616
Assignees
Labels
conclusion: resolved Issue was resolved 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 Oct 28, 2022

Describe the problem

Arduino IDE has a File > Open Recent menu that lists the most recently opened sketches for quick access by the user.

🐛 If a recently opened sketch is deleted, Open Recent is no longer shown under the File menu.

To reproduce

  1. Select File > Save As... from the Arduino IDE menus.
  2. Save the sketch with the name "FooSketch" to any convenient location.
  3. Select File > Open Recent from the Arduino IDE menus.
    🙂 "FooSketch" and any other recently opened sketches are listed (unless you are already affected by the bug).
  4. Select File > Quit from the Arduino IDE menus.
  5. Delete the "FooSketch" sketch you created.
  6. Start the Arduino IDE.
  7. Select File > Save As... from the Arduino IDE menus.
  8. Save the sketch with the name "BarSketch" to any convenient location.
  9. Open the File menu.

🐛 There is no Open Recent menu item. The only way to recover the IDE from this state is to manually delete or remove the deleted sketch entry from the ~/.arduinoIDE/recent-sketches.json file.

Expected behavior

Open Recent menu is still functional after deletion of recently opened sketch.

Arduino IDE version

2.0.1

Operating system

Windows

Operating system version

10

Additional context

I bisected the regression to 2b2463b / #1563 (does not occur when using the tester build for the previous commit 0773c39)
I see this in the logs on IDE startup:

root ERROR Uncaught Exception:
root ERROR Error: ENOENT: no such file or directory, scandir 'c:\Users\per\Documents\Arduino\FooSketch'

Originally reported by @UKHeliBob at https://forum.arduino.cc/t/2-0-1-no-open-recent-menu-item/1046905

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 Oct 28, 2022
@nmzaheer
Copy link
Contributor

I think the relevant code section which raises the error is at Line 196 wherein lstat function raises an error.

async loadSketch(uri: string): Promise<SketchWithDetails> {
const { client, instance } = await this.coreClient;
const req = new LoadSketchRequest();
const requestSketchPath = FileUri.fsPath(uri);
req.setSketchPath(requestSketchPath);
req.setInstance(instance);
const stat = new Deferred<Stats | Error>();
lstat(requestSketchPath, (err, result) =>
err ? stat.resolve(err) : stat.resolve(result)
);

The loadSketch function is called in a try block in the recentlyOpenedSketches function where the catch block is empty which doesn't seem right.

try {
sketch = await this.loadSketch(uri);
} catch {}
if (!sketch) {
needsUpdate = true;
} else {
sketches.push(sketch);
}

However, I am unable to understand the next code block which updates the list of recently opened sketches. If somebody can guide me, I would be able to help submit a PR.

kittaakos pushed a commit that referenced this issue Nov 2, 2022
gracefully handle when sketch folder has been deleted

Closes #1596

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
kittaakos pushed a commit that referenced this issue Nov 2, 2022
gracefully handle when sketch folder has been deleted

Closes #1596

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
@per1234 per1234 added the conclusion: resolved Issue was resolved label Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
3 participants