You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Enabling switching folders all the time?
Enable if <project>/.vscode exists?
Enable if a setting is toggled?
Enable if a setting includes the workspace path? (has issues with multi-folder workspaces)
Reacted by TobiasN, David Gileadi, Will Prater and TiborBremer
Dirty folder 2 workspace (creates .sublime-workspace as a sibling to the .sublime-project)
Close folder 2 (it's allowed even though it's not the last window because it's a "project")
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.
Daniel Imms (@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?
Benjamin Pasero (@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.
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:
Opened a second window
Opened a folder as a workspace
Dirtied some files
Closed it, it exited without prompt
But then I couldn't figure out how to restore the old files and hot exit seems to not work at all any more.
I'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,// 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",}
Since 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:
File > Restore Backed Up Window
Restore all
---
Non-folder window #1
Non-folder window #2
~/dev/Microsoft/vscode
~/dev/Microsoft/vscode
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 nonFolderWindows
Currently 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
We may want to limit the number of backups and/or restores if we allow random window closes to hot exit but all windows to be restored in order to prevent a situation where the PC can't handle launching so many instances at once.
Since it's very easy to quit accidentally now (cmd+q/ctrl+q) with no dialogs and things may not restore in their previous state (unless "windows.reopenFolders": "all"), it might be a good idea to introduce a window.promptOnApplicationExit boolean setting which shows a dialog before application exit.
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?
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:
Closing their other windows
Opening new windows
Their work will not restore until they either kill the application completely via cmd+q or restart the computer.
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.
however only non-folder windows will be restored when the application is restarted (not folder workspaces).
As for the behaviour, when I have appExitAndWindowClose enabled, does this mean when I open another folder in the same window with dirty files, hot exit kicks in and I am not asked to save? Or does that only work when the window I am in is an empty workspace window (given that limitation warning)?
+1 for having this as enum inside the hot exit setting. My only concern is that maybe it should follow our files.autoSave naming and get rid of the obvious app in the name, so it would be onExit and on onExitAndWindowClose
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.
Daniel Imms (@Tyriar) maybe best to see with an example. Let's assume onExitAndWindowClose is set which as far as I understand is the new behaviour we are going to add here.
Can you fill in the blanks what happens in the following cases, assuming each have dirty files:
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 onExitAndWindowClose:
Open folder /foo
Do some work in foo, keep some notes in untitled files, have unsaved text files, etc
Open folder /bar in same window (/foo closes and hot exits)
Some time passes, the main process is shutdown.
VS Code is relaunched but only /bar is restored as it was the last opened folder
When user is ready to resume work on /foo they reopen it and get their backed up untitled and text files restored
Non-folder workspaces act the same as with onExit. We treat them more strictly since it's difficult to identify them and there is no way to restore except for during launch of main process.
Daniel Imms (@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.
Activity
Tyriar commentedon Nov 14, 2016
/cc Benjamin Pasero (@bpasero)
bpasero commentedon Nov 14, 2016
Daniel Imms (@Tyriar) can you elaborate on the issue? you say I loose backups if I switch folders with dirty files opened?
Tyriar commentedon Nov 14, 2016
In Sublime you can do this:
.sublime-projectfor folder 2.sublime-workspaceas a sibling to the.sublime-project)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.
bpasero commentedon Nov 14, 2016
Daniel Imms (@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?
Tyriar commentedon Nov 14, 2016
Benjamin Pasero (@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.
bpasero commentedon Nov 14, 2016
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.
Tyriar commentedon Nov 14, 2016
Yeah that's right. I suggest this be deferred until after #396 is figured out.
Tyriar commentedon Nov 19, 2016
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.
Hot exit documentation
Tyriar commentedon Jan 6, 2017
Proposal
I'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
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:
This is my personal preference for example:
This will probably be a common configuration:
Menu/command to restore
Since 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 nonFolderWindows
Currently 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
"windows.reopenFolders": "all"), it might be a good idea to introduce awindow.promptOnApplicationExitboolean setting which shows a dialog before application exit.bpasero commentedon Jan 6, 2017
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?
11 remaining items
Tyriar commentedon Jan 9, 2017
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.
chrmarti commentedon Jan 9, 2017
I like the single setting that offers the three most predictable behaviors. (After talking to you in person.)
Tyriar commentedon Jan 15, 2017
Benjamin Pasero (@bpasero) Christof Marti (@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
appExitandappExitAndWindowClosedo and mention the synergy with"window.reopenFolders": "all".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.
bpasero commentedon Jan 16, 2017
Daniel Imms (@Tyriar) can you explain to me this limitation:
As for the behaviour, when I have
appExitAndWindowCloseenabled, does this mean when I open another folder in the same window with dirty files, hot exit kicks in and I am not asked to save? Or does that only work when the window I am in is an empty workspace window (given that limitation warning)?+1 for having this as enum inside the hot exit setting. My only concern is that maybe it should follow our
files.autoSavenaming and get rid of the obviousappin the name, so it would beonExitand ononExitAndWindowCloseTyriar commentedon Jan 16, 2017
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 👍
bpasero commentedon Jan 16, 2017
Daniel Imms (@Tyriar) maybe best to see with an example. Let's assume
onExitAndWindowCloseis set which as far as I understand is the new behaviour we are going to add here.Can you fill in the blanks what happens in the following cases, assuming each have dirty files:
Tyriar commentedon Jan 16, 2017
For
onExitAndWindowClose:user closes the window of a folder workspace
Always hot exit
user closes the window of a non-folder workspace
If app exit: hot exit
Else: prompt
user clicks on File > Close Folder in a folder workspace
Always hot exit
user selects File > Open Folder in a window of a folder workspace
Always hot exit
user selects File > Open Folder in a window of a non-folder workspace
If app exit: hot exit
Else: prompt
Tyriar commentedon Jan 16, 2017
Consider the following as an example user flow with
onExitAndWindowClose:/foofoo, keep some notes in untitled files, have unsaved text files, etc/barin same window (/foocloses and hot exits)/baris restored as it was the last opened folder/foothey reopen it and get their backed up untitled and text files restoredNon-folder workspaces act the same as with
onExit. We treat them more strictly since it's difficult to identify them and there is no way to restore except for during launch of main process.bpasero commentedon Jan 16, 2017
Daniel Imms (@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.