microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.38k stars 28.94k forks source link

VSCode never remembers my previous session and doesn't reopen the tabs and project after restart. #36964

Closed mar-ses closed 6 years ago

mar-ses commented 6 years ago

Steps to Reproduce:

Can't reproduce it myself (on another computer with same extensions, settings and version (1.17)

Summary: Every time I open VSCode after computer shutdown, it fails to reopen my previous window. This includes the previous tabs, and the previously open project. Instead it always opens the same project that I opened with (in Explorer) a long time ago, and with only the Welcome tab and the User Settings tab.

  1. Relevant settings:

"window.restoreWindows": "all", "window.openFoldersInNewWindow": "off"

Relevant extensions: Project Manager

  1. I open vscode, and the current tabs are the Welcome and User Settings. The project that is loaded is an old project I opened once with Explorer. I open a new project in a new window (either with Project Manager, or by opening a new window and selecting a new project with the Explorer).

  2. I open a bunch of tabs from that project (and tabs that aren't in that project). If I close VSCode now and reopen it, the tabs, project and everything comes back as expected.

  3. If I restart my computer and open VSCode, my previous session is forgotten, and I have the Welcome tab and User Settings tab open, as well as the old project that I'm not interested in.

What I would expect is that with my settings, it reopens the previous session, with all its tabs and the project that was open at the time in Explorer. I have two laptops, this issue only affects one of them. The VSCode versions are 1.17.1 and 1.17.2 but this has happened in previous versions (1.16) as well. The only difference between the computers is that one has Ubuntu 16.10, the other (the one where the issue strikes) has Ubuntu 14.04 LTS.

Reproduces without extensions: Yes and No (see comment below). Opening without extensions fixed the problem of VSCode opening with the old project, as it now restores the correct project. However it doesn't restore the old tabs.

mar-ses commented 6 years ago

Was checking whether it reproduces without extensions, here's the result:

When I opened code with code --disable-extensions it doesn't reopen my tabs, however now at least the project restored (it didn't open the old project that it was usually opening, but the one I had on last time). This seems to work now when I open with extensions too, however the tabs still don't restore in both cases.

bpasero commented 6 years ago

@Tyriar this sounds a lot like the issue on Ubuntu 17.10 with the task bar shortcut.

Tyriar commented 6 years ago

@mar-ses are you using Ubuntu Gnome?

mar-ses commented 6 years ago

I'm using Ubuntu Unity.

ghost commented 6 years ago

@bpasero Is there any fix for that issue you mentioned? I think I have it too. I'm using VS Code 1.19.3, running on Arch Linux + GNOME, and it will never remember my previous session if I open it through the shortcut, but it does if I invoke it through the console. I also have "window.restoreWindows": "all" set, and I'm using the default .desktop file provided in the AUR package which is this: https://aur.archlinux.org/cgit/aur.git/plain/code.desktop?h=code

Edit: the session is restored via the shortcut only if I leave a file with unsaved changes. Via the console, it is always restored regardless of whether the changes were saved or not. So I'm leaving a dummy file with unsaved changes as a workaround for the time being. :/

mar-ses commented 6 years ago

One thing that happens for me is that I often modify files on two different machines, with the files kept synced automatically (i.e with something like MEGA/Dropbox etc...). If modify a file on one machine that was previously opened on the second machine, then when I try to reopen my session on the second machine, it won't reopen that file.

That's actually one thing that I preferred in Sublime Text, it never had any issues reopening files, even if they had been modified and synced from another machine, and even if they were currently open it seemed to be able to update them or something if I'm not misremembering.

Is this something that can be configured in VSCode? If not, I feel like it would be a useful addition. Perhaps not necessarily being able to modify and sync the files while they are simultaneously open on two machines, but at least so that if I modify them on one machine, the other machine will be able to reopen it (if it had been open on there previously of course).

Also, I can't tell if this issue ended up being fixed for me, or if I just got around it by starting to use the in-built Workspaces.

nurp commented 6 years ago

I am on Windows and have same problem. Workspace is not restored after I restart Windows. The project loads but all the tabs that were open before is now closed. Only happens if I restart windows. The project resides on a linux server, not local on Windows. Wonder if that's related.

nurp commented 6 years ago

It also never re-opens my tabs after an update restarts vscode. It always opens one tab that shows release notes. This is soooo annoying as updates are very often.

Tenemo commented 6 years ago

Same issue, it sometimes does it sometimes not, I can't find any specific trigger for it. Randomly, once in ~10 launches, VSC forgets every file open and disabled extensions. User settings are in place though.

RoyalBingBong commented 6 years ago

Steps to Reproduce:

  1. Start Code
  2. Open a bunch of files
  3. Close Code to save the session
  4. Open Code again
  5. Open additional files
  6. Shut down the PC with Code still open
  7. Start Code
  8. Code will only open the files from step 2.
enkol commented 6 years ago

I've a similar problem. VSCode opens the last folder on start, but not the opened files. It only shows the Welcome page. This doesn't happen always, sometimes it works like expected (opens last folder and restore files/tabs and even unsaved files). Im using VSCode on Windows, but my project folder is on a network drive (mapped to a drive letter). I've already started to open explorer first, to ensure the network drive is there and accessable, before i even open VSCode. The problem still happens unpredictably. I always close VSCode, before shutdown.

Are there any logs i can check, to see why VSCode fails to restore the session?

ahasbini commented 6 years ago

Had the issue with a Blue Screen on Windows 10. VSCode opened the unsaved files however the saved files were not re-opened.

Gruntfuggly commented 6 years ago

On Windows 7, no network drives or anything.

"window.restoreWindows": "all",
  1. Open vscode
  2. Open folder
  3. Close vscode
  4. Open vscode

Just get the screen saying "Show All Command Ctrl+Shift+P, Open File Ctrl+O, etc..."

dotSomething commented 6 years ago

Issue also exists on/with:

OS: Win10 VS Code Version:

Commit: 1dfc5e557209371715f655691b1235b6b26a06be
Date: 2018-07-11T15:43:53.668Z
Electron: 1.7.12
Chrome: 58.0.3029.110
Node.js: 7.9.0
V8: 5.8.283.38
Architecture: x64

Enabled Extensions:

VS Code Settings :

{
    "editor.minimap.enabled": false,
    "editor.parameterHints": false,
    "editor.hover.delay": 2000,
    "workbench.startupEditor": "newUntitledFile",
    "workbench.activityBar.visible": false,
    "javascript.updateImportsOnFileMove.enabled": "always",
    "window.menuBarVisibility": "default",
    "editor.renderWhitespace": "all",
    "editor.insertSpaces": false,
    "window.zoomLevel": -1,
    "editor.acceptSuggestionOnEnter": "smart",
    "editor.lineHeight": 20,
    "editor.detectIndentation": false,
    "files.trimTrailingWhitespace": true,
    "window.restoreWindows": "all"
}
Gruntfuggly commented 6 years ago

I think I know what's going on in my case - it only works if I use Exit from the File menu. Closing all windows doesn't work.

What doesn't help is that there is no default windows keybinding for Exit - I'm used to being able to Ctrl+Q from any app. I've now set one up, and it restores the windows properly.

bpasero commented 6 years ago

Closing as duplicate of https://github.com/Microsoft/vscode/issues/12058