Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upSave UI state periodically to prevent loss on shutdown #12058
Comments
This comment has been minimized.
This comment has been minimized.
|
@jankalfus this indicates that Windows is not shutting down VS Code gracefully but rather terminates it. We would need to periodically save UI state to prevent that. |
bpasero
added
bug
upstream
labels
Sep 15, 2016
bpasero
added this to the Backlog milestone
Sep 15, 2016
bpasero
self-assigned this
Sep 15, 2016
bpasero
changed the title
Editor states are forgotten after Windows restarts due to updates installation
UI state lost when VS Code is terminated ungracefully
Sep 15, 2016
This comment has been minimized.
This comment has been minimized.
|
I have also noticed that when using F12 (Go to Definition), VS Code can be confused with certain files (probably those that weren't existing in the restored state, but were created later). The issue is the following (BTW this relates to TypeScript .tsx and .ts files, I haven't tested any others): |
bpasero
added
workbench
and removed
upstream
labels
Apr 7, 2017
bpasero
referenced this issue
Jun 14, 2017
Closed
Open tabs list is not stored if Windows is shut down #28669
This comment has been minimized.
This comment has been minimized.
JoshuaWalsh
commented
Jun 14, 2017
|
I'm not sure that periodically saving the UI state is the only way to achieve this. With other Windows programs, they appear to be able to execute some code when the computer shuts down. For instance, Paint.NET will prompt you to save any unsaved changes, and will even halt the shutdown until you have given a response. I'm having trouble finding up-to-date documentation about this, but it seems in Vista Windows was changed to allow programs 2 seconds to exit once a shutdown is initiated (https://blogs.msdn.microsoft.com/oldnewthing/20070416-00/?p=27243/), and I can't see any sign that this has been changed since. Would it be possible to use this time to store the UI state? |
bpasero
referenced this issue
Sep 30, 2017
Closed
Visual Code for Windows 10 doesn't restore all windows. On system fail. #35383
bpasero
removed this from the Backlog milestone
Nov 15, 2017
bpasero
added
workbench-electron
workbench
workbench-state
and removed
workbench
workbench-electron
labels
Nov 15, 2017
bpasero
referenced this issue
Feb 12, 2018
Closed
Session (opened tabs) is lost after Code update #43524
bpasero
referenced this issue
Mar 9, 2018
Closed
VS code opens previously closed files at startup when turned of by OS (kubuntu) #45380
This comment has been minimized.
This comment has been minimized.
petermilan
commented
Mar 9, 2018
|
+1 |
bpasero
referenced this issue
May 4, 2018
Closed
"window.restoreWindows": "folders" doesn't work under Linux #49050
bpasero
changed the title
UI state lost when VS Code is terminated ungracefully
UI state/opened folders lost when VS Code is terminated ungracefully
May 4, 2018
bpasero
referenced this issue
Aug 13, 2018
Closed
Windows and Editors not restored after reboot (1.25.1 on Windows 10 1803) #56235
This comment has been minimized.
This comment has been minimized.
youurayy
commented
Aug 13, 2018
|
Why periodically save and why try to save on shutdown? The changes need to be saved as they happen, e.g. new window or tab open, moved or closed -- same thing that e.g. Chrome does with its internal DB. |
This was referenced Sep 6, 2018
This was referenced Sep 13, 2018
bpasero
referenced this issue
Oct 12, 2018
Closed
macOS: updating to a newer version often means UI state is lost #39125
bpasero
added
feature-request
and removed
bug
labels
Oct 15, 2018
bpasero
removed their assignment
Oct 15, 2018
bpasero
changed the title
UI state/opened folders lost when VS Code is terminated ungracefully
Save UI state periodically to prevent loss on shutdown
Oct 15, 2018
bpasero
referenced this issue
Oct 25, 2018
Closed
Unmet expectations when restarting VSCode with Windows, files are not being reopened #61734
bpasero
referenced this issue
Nov 18, 2018
Closed
State lost sometimes when restarting the OS #62844
This comment has been minimized.
This comment has been minimized.
|
From #62844: this also applies to UI state we accumulate on the main side such as the list of opened windows and window dimensions. |
bpasero
referenced this issue
Nov 30, 2018
Closed
Reopen last open workspace not quite working #63976
This comment has been minimized.
This comment has been minimized.
Ruslan0Dev
commented
Dec 8, 2018
|
Where solution? My vscode restore older state instead (After every power failure or critical shutdown). Whereas sublimetext never failed. Please borrow fault tolerance from sublimetext. Thanks. |
bpasero
referenced this issue
Dec 10, 2018
Closed
After windows update auto restart vscode open wrong files #64714
This comment has been minimized.
This comment has been minimized.
Daijobou
commented
Dec 27, 2018
|
Today windows make a update and vscode again lost all actual files and show instead (tabs)files that long ago deleted or moved. So now I must search again ~50 files for my project i'm working with. :( I would wish vscode not only store the actual files before restart windows, its prevent restart when files are not saved at all. Offtopic: I hate windows 10 for his forced restarts. I never shutdown or restart my system. I use hibernate mode, because I have many tools and files open. I hope the next windows is more modern and will be more linux, so restarts are not required. Its feel like year 1995. |
This comment has been minimized.
This comment has been minimized.
youurayy
commented
Dec 27, 2018
|
Iit's possible to disable win10 auto restarts, google it.
But this buggy and very annoying behavior of VSCode could be perfectly
avoided by saving the window presence and position changes as they happen
in real-time, thus not having to worry about abrupt process kills.
…On Thu, Dec 27, 2018, 12:15 Daijobou ***@***.***> wrote:
Today windows make a update and vscode again lost all actual files and
show instead (tabs)files that long ago deleted or moved. So now I must
search again ~50 files for my project i'm working with. :(
I would wish vscode not only store the actual files before restart
windows, its prevent restart when files are not saved at all.
Offtopic: I hate windows 10 for his forced restarts. I never shutdown or
restart my system. I use hibernate mode, because I have many tools and
files open. I hope the next windows is more modern and will be more linux,
so restarts are not required. Its feel like year 1995.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12058 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAj7Hfkf8PKsJ9uor7d9xTnVbTb24Ajtks5u9J3BgaJpZM4J9hZ6>
.
|
usernamehw
referenced this issue
Jan 2, 2019
Closed
Shutting down computer without closing VSCode doesn't open up last opened editor tabs. #65908
This comment has been minimized.
This comment has been minimized.
atiqorin
commented
Jan 9, 2019
|
Regarding closed: #65908. There is something else going on. I did update vscode yesterday. Had atleast 13 tabs pinned and open. 7-8 of them were opened automatically after I started my pc yesterday morning. So while going out of work, as usual I didn't close vscode and shut down my pc. I did restarted vscode two times yesterday. Once after the vscode update and once after I had a corruption on my yarn cache. Few files were probably not opened because before opening vscode, I stashed my changes, merge another branch. Maybe the files that were newly added on my branch were removed while checking out other branch caused the files to not auto open in vscode (Just speculating, I didn't even open vscode while doing the merge or stashing. Opened vscode after I checked out my branch and popping my stash. So the files were there at the time of vscode opening.). Now long story short, when I opened vscode today, just 3 files and an untitled tab were open. One I keep open all the time. Never had issue with that file. One other I am sure I opened yesterday by control clicking the interface usage. Another one was open for 3-4 days. However all the other opened tabs are closed, even the ones that opened yesterday automatically when I opened pc. I don't know how to reproduce this. I believe this is related to this issue and creating another issue will just cause duplication, so commenting here. Thanks. |
This comment has been minimized.
This comment has been minimized.
youurayy
commented
Jan 9, 2019
|
tl;dr this thing is flat broken
…On Wed, Jan 9, 2019, 16:17 Atiq Khan ***@***.***> wrote:
Regarding closed: #65908
<#65908>. There is something
else going on. I did update vscode yesterday. Had atleast 13 tabs pinned
and open. 7-8 of them were opened automatically after I started my pc
yesterday morning. So while going out of work, as usual I didn't close
vscode and shut down my pc. I did restarted vscode two times yesterday.
Once after the vscode update and once after I had a corruption on my yarn
cache. Few files were probably not opened because before opening vscode, I
stashed my changes, merge another branch. Maybe the files that were newly
added on my branch were removed while checking out other branch caused the
files to not auto open in vscode (Just speculating, I didn't even open
vscode while doing the merge or stashing. Opened vscode after I checked out
my branch and popping my stash. So the files were there at the time of
vscode opening.). Now long story short, when I opened vscode today, just 3
files and an untitled tab were open. One I keep open all the time. Never
had issue with that file. One other I am sure I opened yesterday by control
clicking the interface usage. Another one was open for 3-4 days. However
all the other opened tabs are closed, even the ones that opened yesterday
automatically when I opened pc.
I don't know how to reproduce this. I believe this is related to this
issue and creating another issue will just cause duplication, so commenting
here. Thanks.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12058 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAj7HV8t-kFml53XbL-8aqbZeUN0JsGlks5vBfnngaJpZM4J9hZ6>
.
|
usernamehw
referenced this issue
Jan 16, 2019
Closed
Session state is not persisted if VS Code does not cleanly exit #66633
This comment has been minimized.
This comment has been minimized.
agilgur5
commented
Jan 24, 2019
•
|
I'm having this problem on my Mac too, whenever VSCode freezes up or I have to restart my computer, I re-open and I'm back to a state from a month ago :/ (and #66633 is the same problem on Linux) I agree with @youurayy that this feature shouldn't rely on or require a graceful shutdown, one can't guarantee that will ever happen. Makes sense to save the state on-change to prevent this as other tools do |
This comment has been minimized.
This comment has been minimized.
Somebi
commented
Feb 4, 2019
|
Just save the state when closing and opening files and on interval basis, for example once per minute or every 5 minutes if no save was performed? Generate hash and compare, to avoid saving same state again and consume system resources. |
This comment has been minimized.
This comment has been minimized.
ddfridley
commented
Feb 14, 2019
•
|
I agree with Somebi's suggestion. I'll also add that my PC was in standby, when windows 10 did the update. I don't know if that effects what events VS code gets (if any). I'll also add that I wish the state information was stored in each folder that was open (I have 3 separate instances in their own folders open), and then when VS code starts up, it would open up 3 instances again. I understand this is not the most urgent features, and I really appreciate VS Code. Thank you for the work you do. |
Noiredd
referenced this issue
Mar 15, 2019
Closed
Open tabs/windows are not stored properly after an unexpected exit #70481
This comment has been minimized.
This comment has been minimized.
Noiredd
commented
Mar 15, 2019
|
Any attention to this? It's been over 2 years since this was raised. Below, alternative steps to reproduce the issue, independent of your OS:
As a result, you will see tabs A, B and D open. B will be reopened, while C will be lost. |
This comment has been minimized.
This comment has been minimized.
|
Steps to Reproduce:
I never close vscode on my work machine, sometimes power goes down, PC gets rebooted and I have to manually open each file that was opened after vscode launch. Chrome saves opened tab periodically, add this to vscode too. |
This comment has been minimized.
This comment has been minimized.
adbakke
commented
Mar 29, 2019
|
What's the lower-limit of comments on a bug before it gets addressed for this project? |
This comment has been minimized.
This comment has been minimized.
mar-ses
commented
Apr 24, 2019
•
|
Just commenting to also note that this is an issue on Ubuntu with shutdowns (see #36964), although I assume the proposed fix would work for all systems. |


jankalfus commentedSep 15, 2016
Steps to Reproduce:
After logging into Windows and launching VS Code, VS Code opens the project that was opened last time, but it doesn't restore editors to the state they were in last time. It restores some much older state instead (probably from last time the "Close folder" menu option was used). Very annoying.