Store project directory paths as state on AtomWindow in browser process

Fixes #9574

Previously, we were storing the project directory paths as the
`initialPaths` key in load settings, which were accessed in the browser
process by reading the URL hash. However, this URL hash was not always
available, subjecting us to timing issues when opening multiple files
in the same folder in rapid succession.

We now store the project directory paths directly on AtomWindow
instances on creation, then RPC changes from the render process to the
browser process with a custom code path.

Shout out to :airplane::finnadie:’d @as-cii on this for pairing with me.
This commit is contained in:
Nathan Sobo
2015-11-17 21:00:13 -08:00
parent 6b877df0d9
commit d0cb8e2c55
8 changed files with 26 additions and 33 deletions

View File

@@ -151,7 +151,7 @@ describe "AtomEnvironment", ->
[dir1, dir2] = [temp.mkdirSync("dir1-"), temp.mkdirSync("dir2-")]
loadSettings = _.extend atom.getLoadSettings(),
initialPaths: [dir1]
projectDirectoryPaths: [dir1]
windowState: null
spyOn(atom, 'getLoadSettings').andCallFake -> loadSettings
@@ -165,7 +165,7 @@ describe "AtomEnvironment", ->
atom.loadStateSync()
expect(atom.state.stuff).toBeUndefined()
loadSettings.initialPaths = [dir2, dir1]
loadSettings.projectDirectoryPaths = [dir2, dir1]
atom.state = {}
atom.loadStateSync()
expect(atom.state.stuff).toBe("cool")
@@ -173,7 +173,7 @@ describe "AtomEnvironment", ->
describe "openInitialEmptyEditorIfNecessary", ->
describe "when there are no paths set", ->
beforeEach ->
spyOn(atom, 'getLoadSettings').andReturn(initialPaths: [])
spyOn(atom, 'getLoadSettings').andReturn(projectDirectoryPaths: [])
it "opens an empty buffer", ->
spyOn(atom.workspace, 'open')
@@ -191,7 +191,7 @@ describe "AtomEnvironment", ->
describe "when the project has a path", ->
beforeEach ->
spyOn(atom, 'getLoadSettings').andReturn(initialPaths: ['something'])
spyOn(atom, 'getLoadSettings').andReturn(projectDirectoryPaths: ['something'])
spyOn(atom.workspace, 'open')
it "does not open an empty buffer", ->