From dea0e08d93af5cfe278d8ae84d72762de9726cd2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 7 Jun 2013 10:50:06 -0700 Subject: [PATCH] Use hash instead of query string for parameters This allows the pathToOpen to be changed when the project path changes. Previously if the untitled window file was saved, the project path would be forever associated with the undefined window. Now when the project path changes, the pathToOpen changes so that the state is persisted to the project area and the untitled window never has a project. --- src/app/atom.coffee | 7 +++++++ src/app/window.coffee | 5 ++++- src/atom-window.coffee | 2 +- static/index.html | 6 +++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/app/atom.coffee b/src/app/atom.coffee index ded8ab01a..d3001ce72 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -17,6 +17,13 @@ window.atom = getPathToOpen: -> window.location.params.pathToOpen + setPathToOpen: (pathToOpen) -> + window.location.params.pathToOpen = pathToOpen + hashSegments = [] + for name, value of window.location.params + hashSegments.push("#{encodeURIComponent(name)}=#{encodeURIComponent(value)}") + window.location.hash = '#' + hashSegments.join('&') + getPackageState: (name) -> @packageStates[name] diff --git a/src/app/window.coffee b/src/app/window.coffee index 1570b82d9..e1fa70343 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -128,8 +128,11 @@ window.deserializeEditorWindow = -> window.git = Git.open(project.getPath()) project.on 'path-changed', -> + projectPath = project.getPath() + atom.setPathToOpen(projectPath) + window.git?.destroy() - window.git = Git.open(project.getPath()) + window.git = Git.open(projectPath) window.deserializeConfigWindow = -> ConfigView = require 'config-view' diff --git a/src/atom-window.coffee b/src/atom-window.coffee index 155a84221..19a27e8d8 100644 --- a/src/atom-window.coffee +++ b/src/atom-window.coffee @@ -12,7 +12,7 @@ class AtomWindow @browserWindow = new BrowserWindow show: false, title: 'Atom' @handleEvents() - url = "file://#{resourcePath}/static/index.html?bootstrapScript=#{bootstrapScript}&resourcePath=#{resourcePath}" + url = "file://#{resourcePath}/static/index.html#bootstrapScript=#{bootstrapScript}&resourcePath=#{resourcePath}" url += "&pathToOpen=#{@pathToOpen}" if @pathToOpen url += '&exitWhenDone=1' if exitWhenDone diff --git a/static/index.html b/static/index.html index 538cdd566..a8e6ee671 100644 --- a/static/index.html +++ b/static/index.html @@ -5,13 +5,13 @@