-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Hot exit on switching folders #15467
Comments
/cc @bpasero |
@Tyriar can you elaborate on the issue? you say I loose backups if I switch folders with dirty files opened? |
In Sublime you can do this:
These backups are not restored if Sublime is then fully exited and relaunched. We could fairly easily change VS Code to allow this by default, but the concern is that Untitled backups for example could go missing by users accidentally closing the non-last window and not getting it restored. How #396 is solved could impact this as we may need to introduce a project concept. |
@Tyriar but is that 2 folders in the same window or in multiple windows? Do you imply that Sublime enables hot exit in this case even though the user did not enable it? |
@bpasero folder 1 and folder 2 in the above example are in different windows. Hot exit is enabled by default, I'm assuming this is disabled as well when it's disabled. |
Ah so today for us when you close window 2 we ask for saving even though hot exit is enabled? That is the point I was missing. |
Yeah that's right. I suggest this be deferred until after #396 is figured out. |
Looked at Notepad++, it appears to have the same restrictions as Sublime Text where you can only close the last window. It also has a workspaces concept, however I did the following:
But then I couldn't figure out how to restore the old files and hot exit seems to not work at all any more. |
This section be expanded upon when microsoft/vscode#15467 is resolved
ProposalI'm proposing the following to allow hot exit to be more flexible on what types of exits trigger a hot exit and also what exactly is restored on initial launch. Settings{
// Whether hot exit is enabled which allows changes to unsaved files to be
// remembered between sessions. Setting this to false will override all other
// files.hotExit settings.
"files.hotExit.enabled":
true (default) | false,
// What windows with backups should be restored when VS Code is launched (on
// Mac this requires the application to be quit completely).
"files.hotExit.restoreOnStartUp":
"none" | "nonFolderWindows" | "folderWindows" | "all" (default),
// What types of workspaces trigger a hot exit when a single window is
// closed. Note that if VS Code is exited completely via the
// workbench.action.quit command (via command pallete, keybinding of menu),
// a hot exit will always trigger.
"files.hotExit.backupOnWindowClose":
"all" | "nonFolderWindows" | "folderWindows" | "none" (default),
} The settings are hopefully self-explanatory, this had a number of iterations before posting this and I landed on this instead of a few pre-determined configurations as I believe this is a very personal decision since multiple people I asked wanted different things. Also with the above there is no change in the default behavior (conservative). The settings themselves also look much less intimidating when there is only the default value, so power users who want to configure to their desire are free to do so: {
"files.hotExit.enabled": true,
"files.hotExit.restoreOnStartUp": "all",
"files.hotExit.backupOnWindowClose": "none",
} This is my personal preference for example: {
"files.hotExit.enabled": true,
// If I explicitly close a folder window I'll restore it when I reopen the folder.
"files.hotExit.restoreOnStartUp": "nonFolderWindows",
// I'd prefer not to accidentally close non-folder windows but clean up after them.
"files.hotExit.backupOnWindowClose": "folderWindows",
} This will probably be a common configuration: {
"files.hotExit.enabled": true, // (default)
"files.hotExit.restoreOnStartUp": "all", // (default)
"files.hotExit.backupOnWindowClose": "all",
} Menu/command to restoreSince not everything will potentially be restored on launch anymore, a menu and/or command is necessary to surface the currently backed up windows to the user. This is what I'm thinking for the menu item:
The sub menu looks very similar to the Open Recent menu only with no clear (it's too destructive to have in the menu) and it features "Non-folder window #n" which I can't think of a better name for just yet. folderWindows vs nonFolderWindowsCurrently we name VS Code windows with no folder "empty workspaces" and those with a folder open "workspaces", this is confusing to many people and might be even more difficult to get across when multiple root workspaces #396 comes in. In addition it's been suggested we'll move towards identifying windows as windows rather than the workspaces they contain to make multiple windows with the same root #2686. So it makes sense to move the terminology towards something more understandable like this (or similar if there is a better alternative). Other considerations
|
Wow, I am reading through this and even though I know exactly how hot exit works because I reviewed the code and contributed to it I am having a hard time understanding either the need for the settings or the need for a special menu item to restore backup windows. I am also not seeing these options in other applications that support hot exit. I wonder if here we are going a bit too far with what you can configure and should rather just settle on a default that we think is right and leave it like that... Before going much into technical detail of what you want to change, what are the use cases for these changes? |
The main difference is that other editors that support backing up folder not on application exit (np++, sublime) have our conservative default, but will allow it when there is a "workspace file". We don't have a concept of like workspace files that live outside the folder, we have workspace settings but they are inside the folder and won't work for multiple root repositories. The restoreOnStartup setting would enable the user to decide whether they want all backups to restore on launch or a subset depending on window type. The former here would potentially flood the screen with windows which is a big no-no as we're built on electron. Consider the user that keeps vscode open for a week but closes many dirty windows off in the time (easy to do on a Mac), in this case the user could get into a situation where launching vscode creates 50 windows and they fill RAM on launch. |
This issue is the primary use case we want to enable, where folder windows can be closed and they will not necessarily be restored on launch. |
@Tyriar would it be so bad to just restore every folder that has unsaved files on the next full restart? and since we restore backups also when the folder is opened again, a user actually has a way to get back to the unsaved files by just opening them. why do we have to put the workspaces with unsaved files so prominently into the File menu? |
That's just a suggestion in order to make it easier for the user to know what backups VS Code is tracking, it could just as easily be a quick pick via the command palette but that is much harder to discover. The 2 settings are the main things parts of the proposal, but since |
Maybe we should first look into our future of supporting multiple folders in one window and multiple windows on the same folder and thus potentially a similar concept as the workspace file and then decide what it means for hot exit? I am worried that we introduce lots of options and settings that might become obsolete again. |
The options are better in pretty much every way to saving only when a folder(s) are saved as "workspaces" imo. This way users can define whether they just want it to work on all window closes (opt-in) or none (safe default), rather than needing to explicitly save a workspace file (which we wouldn't want to introduce for single folders anyway). |
OK, well I think I expressed my concerns :) |
Another "keep it simple" vote:
This is assuming that |
@chrmarti Backups are restored regardless of whether Are you saying you think hot exit should just happen all the time for window closes as well? This would lead to potentially many backed up workspaces that would be restored on next launch. Consider the following scenario on a Mac:
The reason for the distinction between app exit and window close is if we only hot exit on app exit that means that all backups are visible all the time, reducing the chance backups would go missing or presenting backups from a long time ago (the exception to this being window crashes). |
@Tyriar I suggest to only restore windows as configured with the existing |
I'm hesitant to remove the safe default as some users would expect the dialog and may think changes are already saved. Here's another suggestion in between the current and your suggestion: {
// Whether hot exit is enabled which allows changes to unsaved files to be
// remembered between sessions. Selecting "appExit" means that hot exit
// will only be triggered when the application is closed
// (workbench.action.quit command via command pallete, keybinding of menu),
// all windows will be restored upon next launch. Selecting "appExitAndWindowClose" will
// trigger hot exit when any folder window is closed, however only non-folder windows
// will be restored when the application is restarted (not folder workspaces).
"files.hotExit":
"off", "appExit" (default), "appExitAndWindowClose"
} Here {
"files.hotExit.restoreOnStartUp": "all",
"files.hotExit.backupOnWindowClose": "none"
} And "always" implies these: {
"files.hotExit.restoreOnStartUp": "nonFolderWindows",
"files.hotExit.backupOnWindowClose": "folderWindows"
} |
Another case for why the default should stay as is, consider a Mac user who has some unsaved work in a non-folder window and they close the window, expecting a save dialog. The dialog does not appear and they start to freak out, they try:
Their work will not restore until they either kill the application completely via cmd+q or restart the computer. |
I like the single setting that offers the three most predictable behaviors. (After talking to you in person.) |
@bpasero @chrmarti let me know what you think of this approach, using the single setting as proposed in #15467 (comment). It's working fine from what I can see but it would need a little more testing (plus fixing tests) 1af3873 Note that https://code.visualstudio.com/docs/editor/codebasics#_hot-exit would also go into more detail on what My main concern with this approach is trying to briefly and succinctly differentiate the behaviors in the settings and the setting key itself only explains when the hot exit happens, not the change in restore behavior. |
@Tyriar can you explain to me this limitation:
As for the behaviour, when I have +1 for having this as enum inside the hot exit setting. My only concern is that maybe it should follow our |
That limitation is so people can close folders whrb they're done and open them again when they resume work on the folder. It's essentially this feature, #15467, so it acts more like sublime. The reason all non-folder workspaces are restored is to avoid needing a file menu by maintaining the "backups always visible" property for them. I like the idea of dropped app 👍 |
@Tyriar maybe best to see with an example. Let's assume Can you fill in the blanks what happens in the following cases, assuming each have dirty files:
|
For user closes the window of a folder workspace user closes the window of a non-folder workspace user clicks on File > Close Folder in a folder workspace user selects File > Open Folder in a window of a folder workspace user selects File > Open Folder in a window of a non-folder workspace |
Consider the following as an example user flow with
Non-folder workspaces act the same as with |
@Tyriar got it, I suggest we give it a try. As a mitigation maybe we could eventually add an entry to the File menu "Show previous sessions with backups" (bad name, but you get it) that opens a picker inside the window to select from? If we find out that people are confused by it. |
Parent issue: #101
Sublime has a feature that allows hot exit to always be allowed on a window provided it has a project associated with it. The initial concern still remains that backups may go missing if we just always enable this, the Sublime project system is nice because the act of creating a project (
.sublime-project
) is basically an opt in for project-level features.Interested in people's ideas on this, here are a few:
<project>/.vscode
exists?The text was updated successfully, but these errors were encountered: