-
Notifications
You must be signed in to change notification settings - Fork 28.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
Restore previously opened folders/workspaces when opening a specific folder/workspace #15949
Comments
Try with |
Did that already.. first thing when I got started with it. |
@rajnisheu so you say it does not work with that setting? |
Yes @bpasero |
@rajnisheu I see what is going on. When you instruct Code to explicitly open on a resource (file or folder), we do not restore the windows. So this setting only has an impact when you just launch Code without providing a path. |
I am not sure I can make sense of that @bpasero. To me its not at all intuitive to loose my working session. Its not unusual to right click and use "open file with" command. If Code wasn't open at that time, all working folders and open files are lost. This is offered by several tools, including likes of Notepad++ which remember sessions. I would not call it a feature request. Its fundamental functionality. If it is, its probably unusable by me till we can have that in. Its no fun loosing working folders and files. Thanks for looking into it. |
@rajnisheu what do we do about people that expect "code ." to open exactly one folder which is the folder the "." is pointing to? A change like this always means to potentially break expected behaviour for some users. Since the current behaviour is intended, I set this to be a feature request because this is not something that happens by accident. |
@bpasero I am not able to comprehend why would someone expect For lack of a better example, lets take the case of a browser. If its been set to reopen tabs from last session aka remember last session, and after close, if an html file, say from the desktop, is opened, should the browser loose all tabs? That would be a disaster for a user. |
@rajnisheu how about you double click on a file in the windows explorer to do some quick edits, would you expect all windows to reopen in that case from your previous session? to take it one step further, what about using VS Code as external editor, e.g. to quickly edit a git commit message, would you still expect all windows to open? |
You do make a point @bpasero. But that's not how I see developers working with editors. Editors are open most times. Its those occasional moments when, for example, Windows comes of a reboot (which it does nearly every week ;) ), and you unwittingly double click a file before making sure that Code is open, that loosing session is disastrous. If its a quick edit of a Git message, it would most likely be for a project. Editing a message.. and loosing the session! I can tell you working with a reasonable size team, single message edits are always in Git tool directly or even command line. I can't imagine working with a modern tool where I am likely to loose my project setups, tasks and several open (and sometimes unsaved) files, even accidentally. In the end, if I have set session to be remembered, that's what I would expect. Extra seconds spent for loading is any day far more acceptable than loosing work! Thanks for the clarification though, you can close this thread if you wish. |
@rajnisheu I took extreme examples, but that is the reason why " Now, wether this behaviour is good or bad is up for discussion and that is why I will leave this issue open and flag it as feature request. I am not saying that our behaviour is good or bad, just saying that it is a result of us interpreting " |
@bpasero its the same behaviour with Code installed and doing a right click Previous session is lost. Is that really the expected behaviour? |
Yes, as long as Code is opened on a specific path (either file or folder), we use that as the session over any previous session. At least that is a consistent behavior I would say. |
I agree with rajnisheu. Anytime I reopen Code it should automatically reopen all the files I had open previously. If I double click or use the context menu to open a file, it should also show all the previously opened files in their respective tabs, along with the file I wanted opened. The editor doesn't have to actually load those other files until the user clicks the appropriate tab. Personally, I never have files open from just a single folder. Multiple files are open from multiple folders across multiple drives. Notepad++ does it right. I can even use a tab in Notepad++ as a temporary copy/paste buffer. I never have to save the file. At the VERY least you should make it a setting so those who want Code to work the way Notepad++ does, they have that option. Great editor. Love the plugins, Love the themes. It won't replace my current editor if it doesn't automatically open all of my last file. This is especially true since Windows 10 WILL reboot after an update if even you have the settings otherwise. That's a different issue altogether. |
Thanks @37Stars, several users I know and I abandoned Code and decided to stick to Notepad++ / other IDEs. The other extremely helpful feature in Notepad++ is the ability to save sessions. This means if I have two (or even more) multi tab instances of NP++ open, I can save these and come back to exactly what I was doing including unsaved tabs after the notorious WIN10 update. NP++ does get it right! |
What you want is #207 and not this issue. |
I think your ideas sound good, but I agree with @lautjy that users will continue to be confused by the existing behavior which I consider broken. Why can't you "break existing behaviour"? Defaults can be changed to be better. |
@jimjoh I think it can cause frustration too if this was the default. For example, you may decide to use VSCode as editor for git commit messages and anytime VSCode opens to show the git editor, suddenly all other windows and editors would restore if it was not running before. I agree that a nice feature would be to be able to restore windows + editors from previous sessions as a way to get back to the last state even when meanwhile a single editor was opened. Btw I just checked how browsers do it, and Chrome for example does not seem to put "Continue where you left off" as a default: |
Your analogy to browsers is not entirely appropriate. Unless you use extensions to do so, browsers don't save user-entered information when they are shut down (like form fields), so less total and less important information can be lost if a session is lost. Further and far more importantly, browsers have different behavior when they crash, and I think it's getting lost a bit in this conversation that part of this bug is the loss of unsaved data when vscode crashes. If you want to analogize to browsers, you need to provide a different workflow with a prompt to the user to restore their session if the program closed unexpectedly. I still can't believe we need to argue this. Literally every program/platform/app that I use to enter text can restore my "unsaved" data after the program or computer crashes. Sublime, Atom, VSCode, MS Office, Libreoffice, Google Docs, Evernote... This is a standard feature in even remotely capable text editors for the last ten years. VSCode is the only one that throws this feature away because the user happens to relaunch the program in a specific entirely usual way. |
@sparr I cannot follow your argument. Are you implying that VSCode is loosing unsaved data in any way? |
Yes. When VSCode throws away the saved session because you opened a specific target file or folder, that session can include unsaved files/buffers. Search up-thread for "unsaved" or "buffer" for other people pointing out this failure mode. Reproduction steps:
At this point your "foo" seems to be irretrievably lost. If your step 1 had targeted a specific directory like |
@sparr understood, I forgot about a change we did in March: #92467 (cc @aeschli) where we no longer open folders/workspaces that contain dirty files. Fact is, we lost this behaviour for a couple of months and then decided to not bring it back because it resulted in a sudden spawn of tons of windows for users that accumulated dirty files in various folders and workspaces. Our UI solution was then to indicate workspaces with dirty files in the picker with a black dot: Still, this is NOT data loss. You will always see your recent workspaces in VSCode to navigate to and whenever you navigate back in you will get your dirty files back. To summarise:
I feel the original intent of this issue was to restore the windows and editors independent from having files dirty or not. Arguably we could introduce a setting that would only restore those windows with dirty files, but I feel that is not really what people asked for here. Does that make sense? |
@bpasero I am the original poster of the issue, and am glad this is being visited four years on! Better late than.. :) What you say in #15949 (comment) is exactly what I think the behaviour should be. Most people understand the implication of opting for "Continue where you left off". And that is what VSCode should do. As with the browser, or infact similar tools, if there were 15 windows open, all should restore. If VSCode can handle opening an isolated instance for git diff or git commit, good. But not at the cost of loosing work. In any case there are other possibilities to handle diff or commit as well. With this feature, and multiline tabs, VSCode will achieve awesome 🥇 and can become a truly mainstream IDE 👍 |
@bpasero I do not understand how to apply your description to the reproduction steps I provided above. How can I recover my unsaved "foo" file? |
@sparr that depends wether the untitled file is part of a folder/workspace context or an empty window:
|
That's amazingly useful and not at all intuitive. Thanks to this advice I've been able to recover three dirty workspaces with unsaved files that I thought were lost. Sadly the one I most regret losing, the one that brought this bug to my attention, is not represented in that picker. I only wish I'd known to check there when it happened. |
This is totally how I would expect it to work, huge 👍 ! |
I presented this in our UX meeting and think we can push this to insiders for feedback. One discussion was around the name of the setting. The existing proposal was to have a new setting that controls this behaviour, however it might be very confusing given we have How would people feel if we added another option to
Thoughts? |
Sounds good to me! |
I have pushed One potential feature request I already see is to support |
Ah, |
@bpasero what determines what window the file opens in? |
In a perfect world, it would open in the same place that it would have opened if you'd already had vscode running and opened the file from outside the program, which I think depends on whether or not the file is within any existing open workspace. |
@jonatino yes I think @sparr described it well. The experience of opening a file will be the same independent wether VSCode is running or not. We have some logic that tries to find the best window when opening a file. E.g. ensuring that a file opens in the window where the parent folder is opened in. |
This can now be tested from our insiders release channel: https://code.visualstudio.com/insiders/ |
Steps to Reproduce:
code .
Atom has exactly the same issue :)
The text was updated successfully, but these errors were encountered: