This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
Store/retrieve state from windows that have no opened project #19557
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR attempts to solve the root issue that causes the confusion around the "Restore previous window on start" config setting (reported in atom/settings-view#1129).
Problem
The root problem is that in order to store (or retrieve) an editor window state, Atom uses the list of folders that are currently opened as the key. This is a simple approach but has the limitation that cannot be used to store the state when opening a single file or a set of files (as feature which was introduced in #18608).
Solution
In order to fix this, I've introduced the
windowId
param, which is a unique identifier for eachwindow
which is used for storing and retrieving the state of windows that do not have any opened project.This allows to keep the full state of Atom windows (even if there are many windows without any opened project) when opening Atom without passing any arguments.
Major drawback
There's a big drawback on this solution, which IMHO we need to fix before considering merging it: Since there's no cleaning mechanism on the
StateStore
(theIndexedDB
database which keeps the state of the Atom windows), adding this logic will make its size increase indefinitely, since window identifiers will get generated every time a new Atom window without a project gets created (so e.g every time a user runsatom Readme.md
).This problem is already happening on
master
, since every time that a user opens a folder on Atom, this folder state will permanently be stored on theIndexedDB
database, but with this PR the issue is amplified considerably (specially for people that use Atom to edit single files).Next steps
As I mention, I don't think this PR is shippable in the current state, but I've sent it anyways to:
StateStore
a LRU cache.