mirror of
https://github.com/atom/atom.git
synced 2026-01-21 04:48:12 -05:00
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:
@@ -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]
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user