Description
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
- Select File > Save As... from the Arduino IDE menus.
- Save the sketch with the name "FooSketch" to any convenient location.
- 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). - Select File > Quit from the Arduino IDE menus.
- Delete the "FooSketch" sketch you created.
- Start the Arduino IDE.
- Select File > Save As... from the Arduino IDE menus.
- Save the sketch with the name "BarSketch" to any convenient location.
- 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 trackerI verified the problem still occurs when using the latest nightly buildMy report contains all necessary details
Activity
nmzaheer commentedon Oct 29, 2022
I think the relevant code section which raises the error is at Line 196 wherein
lstat
function raises an error.arduino-ide/arduino-ide-extension/src/node/sketches-service-impl.ts
Lines 189 to 198 in 0d05509
The
loadSketch
function is called in atry
block in therecentlyOpenedSketches
function where thecatch
block is empty which doesn't seem right.arduino-ide/arduino-ide-extension/src/node/sketches-service-impl.ts
Lines 392 to 399 in 0d05509
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.
feat: generalized Node.js error handling
feat: generalized Node.js error handling
fix: Handle gracefully when trying to detect invalid sketch name erro…