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.
This commit is contained in:
Kevin Sawicki
2013-06-07 10:50:06 -07:00
parent fca1c13d03
commit dea0e08d93
4 changed files with 15 additions and 5 deletions

View File

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

View File

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

View File

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

View File

@@ -5,13 +5,13 @@
<script>
window.location.params = {}
var params = window.location.search.substring(1).split('&')
var params = window.location.hash.substring(1).split('&')
params.forEach(function(param) {
var pair = param.split("=")
var pair = param.split("=");
window.location.params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
});
window.resourcePath = window.location.params.resourcePath
window.resourcePath = window.location.params.resourcePath;
var bootstrapScript = window.location.params.bootstrapScript;
window.onload = function() {