cocalc
cocalc copied to clipboard
make closing all the frames for a file, just close that file
If you have a file open right now and close all of its frames, currently the frame tree gets reset to the default layout. This was a sort of (probably undocumented) hack to make it possible to restore the default layout. However, now we have a new menu item that restores the default layout:
I think it would be natural to make it so if you close the upper right only remaining x for a file, i.e., the last frame, then the file just closes (and the frame tree stays as is).
Code wise this would be a very easy change to make (probably 2-3 lines). Any thoughts? @novoselt ?
Yes, please! How can one discover the old behaviour except by accident and how easy it is to guess what exactly is going on? Closing the last frame and the file entirely seems way more intuitive.
I don't like closing the file, because then the functionality of that x button "transcends" to another type of functionality. Rather, I would close the last frame and show some kind of "default view", where it says what file this is, has some buttons to open frames again, restore the default, and maybe even close the file.
I would close the last frame and show some kind of "default view",
This reminds me of the Home button for a project, where it involves adding some new UI elements to cocalc to fill an empty space. However, there's no clear sense of what those UI elements are or that they are actually needed. It just feels like an opportunity to add complexity and confusion. Moreover, if we have such a page, we will inevitably add some sort of actually useful functionality to it. At that point, do we end up with people having to close all frames to get to that functionality?
What do other programs do in this case?
- vscode (and jupyterlab): not really the same problem -- every "frame" is its own full file tab and the only way to close anything is by clicking on a tab x. You can have multiple views of a file in vscode and there is nothing special about closing the last one. They all close in the same way.
- emacs: not really the same problem -- Shows an error message: "attempt to delete ... sole ordinary window". Basically this is making clicking that last close x an error or disabled.
- tmux: EXACTLY the same problem -- when you close the last frame it closes the entire thing. I.e., it does exactly what I'm proposing here. The only difference is that it is a terminal and not a file.
Question: take a random new user to cocalc. They are looking at this in the UI and they decide "I'm clicking on that x in the far right":
What do they expect will happen?
- the file closes,
- something else involving: "[...] some kind of "default view", where it says what file this is, has some buttons to open frames again, restore the default, and maybe even close the file."
I would guess 1 is more likely; they are not likely to be expecting 2, since it's not even clear what 2 would be, and you can't expect the unknown.
Note that emacs does implement a third option, which is "show an error".
For this problem I think there are really two viable solutions which align with most user expectations and do not add complexity to the UI:
- close the file
- disable the x button, if this is the only frame.
Option 2 seems to be basically what emacs does. Emacs is most similar to cocalc regarding this problem.