go-playground icon indicating copy to clipboard operation
go-playground copied to clipboard

Automatic save of code in localstorage

Open DamianFekete opened this issue 2 years ago • 4 comments

Hi Denis,

It would be nice if the code would be saved automatically, so that a refresh of the page / restart of the browser won't lose the changes. I, for example, use Ctrl-W in IntelliJ a lot, which would close the browser window. I think that the local storage could be used, for example like in https://godbolt.org/

image

Issue can be of course closed if not in the scope of the project.

Best regards, Andrei

DamianFekete avatar Apr 15 '22 14:04 DamianFekete

@DamianFekete it's considerable but I'm also looking for a contributor. If you feel that users might benefit for the issue - looking forward for contributions.

x1unix avatar Apr 15 '22 15:04 x1unix

@DamianFekete I was thinking on some edge cases that need to be resolved to properly implement this:

  • What is the best way to provide an option to "reset" the state of the editor. There is a context menu item right now, but not sure if it's clear enough.
  • How multiple tabs case should be handled. Let's imagine I opened two separate tabs with different code and I touch both in interval of 5-10 mins. What tab should have priority?

Also, I was thinking about adding multiple files support per snippet (if it will be a popular idea), so solution need to consider that also.

Please share your thoughts.

x1unix avatar Apr 15 '22 22:04 x1unix

@x1unix, thanks for your reply. All good questions and I don't think I have answers for them.

There is a context menu item right now, but not sure if it's clear enough.

I've just started using goplay and I didn't notice the down chevron until now. Maybe adding a label (like Templates? Examples?) would be helpful for others too.

image

Either that, or add a New... with a drop-down list to reset the current state to either an empty file or a template.

How multiple tabs case should be handled.

Maybe always displaying the information from the last tab active, with an option to see the history. This may involve too much work and at some point people may install a standalone editor/IDE. image

Also, I was thinking about adding multiple files support per snippet

Will this be in different windows or in one window, the files being separated by something like --- file2.go ? I've seen this somewhere the past week, but I can't remember where.

DamianFekete avatar Apr 17 '22 14:04 DamianFekete

I've just started using goplay and I didn't notice the down chevron until now. Maybe adding a label (like Templates? Examples?) would be helpful for others too.

Good point, I was also thinking about that but also was looking for other options because there are too many buttons already there.

Would like to hear a couple of good UI/UX ideas

Probably the whole menu should be re-organized.

Will this be in different windows or in one window, the files being separated by something like --- file2.go ? I've seen this somewhere the past week, but I can't remember where.

The original Go playground allows code splitting as separate files using special comment (something like ---) but at the end it will be a long snippet separated by comment section.

x1unix avatar Apr 17 '22 21:04 x1unix

This issue is stale because it has been open for 15 days with no activity. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar Jan 10 '24 02:01 github-actions[bot]

I also agree autosave option would be useful (unfortunately not DEV here, rather beginner). It happens so many times to me that I close browser and code is lost. Thank you for the great pkg anyway :+1:

smjure avatar Jan 19 '24 16:01 smjure