Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Compute a state key even if there are no project folders - #11122

Closed
mehcode wants to merge 1 commit into
atom:masterfrom
mehcode:patch-2
Closed

mehcode wants to merge 1 commit into
atom:masterfrom
mehcode:patch-2

Conversation

@mehcode

@mehcode mehcode commented Mar 10, 2016

Copy link
Copy Markdown
Contributor

This allows for state to be saved without a project folder added.

Would fix #10474


I can add a spec for this if this something we want.

else
null
# Represents an empty editor (no project folders)
"editor-<empty>"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely blanking on a good name here

@winstliu

Copy link
Copy Markdown
Contributor

/cc @as-cii @nathansobo

@alexandernst

Copy link
Copy Markdown

How will this behave with multiple instances without a project folder? Will it restore all instances or will it restore just one instance with all the tabs from all the instances?

@winstliu

Copy link
Copy Markdown
Contributor

@alexandernst Wouldn't having separate instances share the same serialization state? So if you edit some files without a project, then open a new Atom window, shouldn't those same files show up?

(Also, this should adhere to the openEmptyEditorOnStartup option)

@alexandernst

Copy link
Copy Markdown

@50Wliu No, not really. At least here, opening multiple instances opens completely separate windows that do not share any of the open files (neither existing nor unsaved buffers).

@leobasilio

Copy link
Copy Markdown

I might be wrong, but isn't this return value used as the file name? < and > are not valid file name characters. Why don't you just return the sha for an empty string by removing the "if paths?.length > 0"?

@mehcode

mehcode commented Mar 15, 2016

Copy link
Copy Markdown
Contributor Author

@leobasilio States got moved to IndexedDB. They are no longer in ~/.atom/storage. I wanted the state name to be something that clearly indicated empty.. but your way would work nice too.

@rreinhardt

Copy link
Copy Markdown

This is great! Looking forward to this getting rolled in but I will share that it does not quite work as expected right now if multiple windows are opened.

e.g.

Start Atom
Add text in Untitled (1) in Window (1)
Create New Tab Untitled (2) in Window (1) & add text
Create New Window & add text in Untitled (1) in Window (2)...

If you bail on Atom, anything in Window (2) is lost. Atom will restore two Windows but both will contain tabs from the first Window (1) in the above scenario. Continuing to edit in Window (2) will not get acknowledged in subsequent exits/restores.

Additional weird behavior is if you create a new window, after serialization, the new document in the new window will contain the text from the previous window.

All in all, this is a huge improvement to behavior in v1.6 — currently there is not even 'save' dialogs before exiting/dataloss.

As long as there is one 'no project' window open, things should work as you'd think.

@mehcode

mehcode commented Mar 22, 2016

Copy link
Copy Markdown
Contributor Author

[...] As long as there is one 'no project' window open, things should work as you'd think.

Hmm.. I'm not sure how to solve what you're describing. This probably requires some more thought rather than a quick patch, as the solution to what you describe sounds involved. Perhaps each non-project window has some sort of unique identifier and we remember these identifiers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unsaved buffers aren't restored if there is no project folder added to the window

5 participants