The Wayback Machine - https://web.archive.org/web/20190509055147/https://github.com/Microsoft/vscode/issues/12058
Skip to content
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

Save UI state periodically to prevent loss on shutdown #12058

Open
jankalfus opened this issue Sep 15, 2016 · 18 comments

Comments

Projects
None yet
@jankalfus
Copy link

commented Sep 15, 2016

  • VSCode Version: 1.5.2
  • OS Version: Windows 10

Steps to Reproduce:

  1. Let VS Code open, lock the computer
  2. Let Windows install updates and automatically restart the computer

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.

@bpasero

This comment has been minimized.

Copy link
Member

commented Sep 15, 2016

@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 bpasero added this to the Backlog milestone Sep 15, 2016

@bpasero bpasero self-assigned this Sep 15, 2016

@bpasero 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

@jankalfus

This comment has been minimized.

Copy link
Author

commented Sep 18, 2016

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):
When using F12 with a symbol, VS Code opens a new editor tab with an identical file opened and sets the cursor at the import, instead of going to the symbol import in the currenty opened editor tab. Expected behavior is to just set the cursor in the currently opened tab.

@JoshuaWalsh

This comment has been minimized.

Copy link

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?

@petermilan

This comment has been minimized.

Copy link

commented Mar 9, 2018

+1

@bpasero 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

@youurayy

This comment has been minimized.

Copy link

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.

@bpasero bpasero added feature-request and removed bug labels Oct 15, 2018

@bpasero bpasero removed their assignment Oct 15, 2018

@bpasero 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

This comment has been minimized.

Copy link
Member

commented Nov 18, 2018

From #62844: this also applies to UI state we accumulate on the main side such as the list of opened windows and window dimensions.

@Ruslan0Dev

This comment has been minimized.

Copy link

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.

@Daijobou

This comment has been minimized.

Copy link

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.

@youurayy

This comment has been minimized.

Copy link

commented Dec 27, 2018

@atiqorin

This comment has been minimized.

Copy link

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.

@youurayy

This comment has been minimized.

Copy link

commented Jan 9, 2019

@agilgur5

This comment has been minimized.

Copy link

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

@Somebi

This comment has been minimized.

Copy link

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.

@ddfridley

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

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:

  1. Launch an existing session of Code, say there are files A and B open
  2. Close tab B
  3. Open an existing file C but don't make any modifications to it
  4. Create a new tab (let's call it D) and write "foo" in it, without saving
  5. Kill the code process (or hard-reset your machine)
  6. Launch Code again

As a result, you will see tabs A, B and D open. B will be reopened, while C will be lost.
If you created a new window and only used it to view existing files (more of the C case), this will mean the loss of an entire window. If you had multiple windows and closed one of them before step 5, it will be revived.

@Yanpas

This comment has been minimized.

Copy link
Contributor

commented Mar 29, 2019

Steps to Reproduce:

  1. Open vscode
  2. Open some files, wait some time
  3. killall -9 code
  4. Open vscode again, these files are not opened

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.

@adbakke

This comment has been minimized.

Copy link

commented Mar 29, 2019

What's the lower-limit of comments on a bug before it gets addressed for this project?

🤔

@mar-ses

This comment has been minimized.

Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.