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

Restore open sketches on startup #780

Merged
merged 1 commit into from
Feb 11, 2022

Conversation

msujew
Copy link
Contributor

@msujew msujew commented Jan 27, 2022

Closes #384

Stores sketches which were closed immediately before the application closed in the electronStore of the main app. When restarting the application, the sketches are loaded and a dedicated window is launched for each of them.

The fix needs some special treatment for Windows. Due to my local setup, I was not able to test this on a POSIX system. although I'm quite certain it should work there as well.

@per1234
Copy link
Contributor

per1234 commented Jan 28, 2022

Hi @msujew

The fix needs some special treatment for Windows.

I'm not sure whether I understood correctly. Is the current build from this PR expected to work on Windows?

@per1234 per1234 added status: waiting for information More information must be provided before work can proceed topic: code Related to content of the project itself labels Jan 28, 2022
@msujew
Copy link
Contributor Author

msujew commented Jan 28, 2022

@per1234 Yes, it definitely works on Windows, since it is the OS on my dev machine. On the other hand, it needs some testing to confirm it works on posix systems from your side.

@per1234 per1234 removed the status: waiting for information More information must be provided before work can proceed label Jan 28, 2022
@per1234 per1234 self-requested a review January 28, 2022 11:23
Copy link
Contributor

@AlbyIanna AlbyIanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on MacOS. Looks very good to me! 🚀
@silvanocerza would you please give it a try on Linux? 🙏

Copy link
Contributor

@silvanocerza silvanocerza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works fine for me on Linux. 👍

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not working for me on Windows 10

To reproduce

  1. Start the Arduino IDE.
    You now have a sketch open (I'll refer to it as "sketch a").
  2. Open another sketch (I'll refer to it as "sketch b").
    You now have two sketches open.
  3. Select File > Quit from the Arduino IDE menus.
  4. Start the Arduino IDE

🐛 I now have two windows, each of which has "sketch b" open.

image

Expected behavior

Starting IDE opens "sketch a" in one window and "sketch b" in the other.

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The procedure I described above works correctly for me on Linux, however, I experienced a different problem on Linux:

To reproduce

  1. Start the Arduino IDE.
    You now have a sketch open (I'll refer to it as "sketch a").
  2. Select File > New from the Arduino IDE menus.
    You now have a second sketch open, staged in a temporary folder (I'll refer to it as "new sketch").
  3. Select File > Quit from the Arduino IDE menus.
  4. Start the Arduino IDE

🐛 I now have two windows, each of which has "sketch a" open.

Expected behavior

Starting IDE opens only a single window, containing "sketch a".

@msujew msujew force-pushed the msujew/multi-workspace-startup branch from afab6bf to d9a937c Compare January 31, 2022 13:14
@msujew
Copy link
Contributor Author

msujew commented Jan 31, 2022

@per1234 Thanks for the throughout review! I was able to reproduce both issues. The Windows one had some specific conditions: I was able to reproduce the issue by saving the sketch to a different drive.

The Linux issue stems from the OS deleting the temp folder. We now check for that before opening the window.

Both issues should now be hopefully fixed.

@per1234 per1234 self-requested a review January 31, 2022 13:28
@silvanocerza
Copy link
Contributor

I confirm the issue on Linux reported by @per1234 is fixed, even creating multiple sketches and not saving them works with no issues.

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything working perfectly for me now on both Windows and Linux.

And indeed I did happen to have sketches "a" and "b" saved on a different drive from the IDE when I encountered the Windows issue I reported previously.

Thanks @msujew!

@ubidefeo
Copy link

ubidefeo commented Feb 2, 2022

@msujew , it works on Mac OS Monterey, any chance we can save the windows state including positioning and size?

@msujew msujew force-pushed the msujew/multi-workspace-startup branch from d9a937c to 6c749f6 Compare February 2, 2022 15:21
@msujew
Copy link
Contributor Author

msujew commented Feb 2, 2022

@ubidefeo Didn't think about that, I added that as well 👍

@ubidefeo
Copy link

ubidefeo commented Feb 2, 2022

awesome!

@ubidefeo
Copy link

ubidefeo commented Feb 2, 2022

@msujew
I tested the build, and the first document still takes a small offset from TL corner.
I set the windows as
1: quadrant top left
2: quadrant bottom left
3: right side of the screen

When I relaunched I got this
CleanShot 2022-02-02 at 17 40 34@2x

@silvanocerza
Copy link
Contributor

What happens if I close the IDE on a secondary monitor, disconnect it and then open the IDE again? 👀

@msujew msujew force-pushed the msujew/multi-workspace-startup branch from 6c749f6 to 2387156 Compare February 2, 2022 17:31
@msujew
Copy link
Contributor Author

msujew commented Feb 2, 2022

@ubidefeo Do you mind retesting it? I believe the offset was introduced by a incorrect call to avoidOverlap. However, I'm not quite sure about that, since I couldn't test it on a Mac.

@per1234
Copy link
Contributor

per1234 commented Feb 2, 2022

close the IDE on a secondary monitor, disconnect it and then open the IDE again?

Arduino IDE 1.x has had problems with this sort of thing:
arduino/Arduino#5581

@ubidefeo
Copy link

ubidefeo commented Feb 4, 2022

@msujew
I have not tested the very latest yet, but just launched the build I was testing and only one Sketch is open, aligned top-left.
I quit the IDE with two open Sketches and tried 3 times, the previous "session" is not restored

@msujew
Copy link
Contributor Author

msujew commented Feb 7, 2022

@ubidefeo Are you perhaps opening "new" sketches, which get automatically deleted by the OS after closing the IDE? This is what caused the issue here, but now the IDE does not try to reopen deleted sketches.

@msujew
Copy link
Contributor Author

msujew commented Feb 10, 2022

@per1234 @AlbyIanna I would merge this if that's alright with you? Having this PR in would make working on #72 and #370 easier.

Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried the latest build out on both Windows and Linux and everything is still working perfectly for me.

So merging it is alright with me.

@fstasi fstasi merged commit 69ac1f4 into arduino:main Feb 11, 2022
@msujew msujew deleted the msujew/multi-workspace-startup branch February 11, 2022 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Restore last open Sketches at launch
6 participants