pharo
pharo copied to clipboard
Closing windows with Cmd+W may lead to bad user experience
To open a new Playground window, we use the Cmd+OW shortcut (Mac OS), but it is very easy to press Cmd+WO instead (we press Cmd and W with left hand and O with right hand). And this will close the current window, because that's the function of Cmd+W.
In case of a System Browser, we get a question "Is it OK to discard changes?". But Playground closes without any warning, so we lose everything that we have typed.
Consider this scenario (it happens to me all the time):
- You open Playground A and write some code in it
- You press
Cmd+OWto open Playground B - Accidentally, you press
Cmd+WOinstead, which closes Playground A and flushes your code (and yes, you can restore it from play-cache, but it's still very unpleasant).
I don't know if it's easy to make those changes, but I suggest one of the following enhancements:
Option 1: Change Cmd+W to some other shortcut that is not easy to press by accident
Option 2: Show a warning before closing a non-empty Playground (same as in System Browser)
Related to https://github.com/pharo-project/pharo/issues/3393
I'm not in favor of the option 1. it is the default to close any window in most of the software, and it should be the same in Pharo. I'll prefer that the playground shortcut CTRL+OW change to another one.
Further more, a warning will be nice when we close the playground!
Just two thoughts:
-
the "W" came historically from Workspace as in Smalltalk tradition, with GT the Playground was introduced "abusing" the same shortcut
=> I think it would be more recognizable if we rename into Workspace again to suit the "W" or use possibly "P" for Playground, no?
-
there is already a new Playground prepared by @estebanlm in the NewTools project for Spec2 (StPlayground)
I propose another option: instead of bothering the user with a warning about closing a non-empty Playground, save its contents and restore it when the Playground is reopened. Seeing a warning and confirming it every time is probably not the best solution.
I would like also to have an explicit save button even if it feels counter design. I lost contents in the past and I'm fed up to lose them.
The content of the playground is already saved when closing, nothing can be lost, as this method shows:
stopProcessing
"A playground does not steps, but it needs to force a flush of last changes"
self firstPage ensureContentsFlushed
this method is called in windowClosed and in lost focus event, so I think if there is data lost, this is a bug and not something that may be workarounded with a save button (which indeed, does not fits the design). AFAIK, the data loss of @Ducasse was handled when I ensured the flush on close (it was not like that before) and by adding also the Versions of the page (along with the page).
@olekscode , how do you lose the content? Did you verify it is not in the "pages" ?
yeah, just verified and is not possible that you actually lose information. So in fact what you "lost" should be there and yes, you need to open "pages" to recover it (but it will be first option, as pages list is sorted recent to older)
Esteban I garantee that I lost contents. Now you can not believe me and believe that it is not possible. It happened to me when I was coding with guille and since we were doing crazy stuff I should have copy paste it in an external tool :( And at the end I retyped it. And for me I lost contents without closing the playground. I lost contents because the image crashed before the playground could save :( and because I could not decide when to save the contents, of course because this smart tool is not smart enough.
I do not get why you do not listen to the users. At the end people will look for other tools or they will say Pharo is cool but the UI could be better.
For example in the past we could create a file pressing on a button in the inspector and now we cannot so you have to use a texteditor to add a preference file. Before it was just there. This is why some people prefer GTtoolkit.
I do not really know why I commented this issue. I should add a button to playground and save that in my pharo extensions. I feel like talking in the desert at the end. You see if you want to know you should ask people around their point of view. I do not trust this tool. So I write my scripts in class methods because like that I have the history in Epicea. But do not come and tell me that I do not lose scripts because I do.
Just a proof that the Playground can lose code. Type
Smalltalk quitPrimitive
and execute it. Your expression is not saved! it means that any expression leading to an infinite loop or cr ash will never be written. Tested on P11.
So Playground is only done for nice and clever programmers that do not write code that crash. The others are just pain idiots that can retype. I always feel insulted when such a tool blew my code off. So at the end I only use it for stupid things.
Now if I could save the expression before executing it. But this is a too advanced feature I imagine. Too user friendly probably. After more than 2 years telling this, I'm just sad for Pharo.