mirror of
https://github.com/atom/atom.git
synced 2026-02-09 14:15:24 -05:00
Now storing a window's state based on its rootDirectory (instead of on windowNumber)
This commit is contained in:
@@ -2,5 +2,20 @@ fs = require('fs')
|
||||
|
||||
atom.configDirPath = fs.absolute("~/.atom")
|
||||
atom.configFilePath = fs.join(atom.configDirPath, "atom.coffee")
|
||||
atom.open = (args...) -> @sendMessageToBrowserProcess('open', args)
|
||||
atom.newWindow = (args...) -> @sendMessageToBrowserProcess('newWindow', args)
|
||||
|
||||
atom.open = (args...) ->
|
||||
@sendMessageToBrowserProcess('open', args)
|
||||
|
||||
atom.newWindow = (args...) ->
|
||||
@sendMessageToBrowserProcess('newWindow', args)
|
||||
|
||||
atom.getRootViewStateForPath = (path) ->
|
||||
if json = localStorage[path]
|
||||
JSON.parse(json)
|
||||
|
||||
atom.setRootViewStateForPath = (path, state) ->
|
||||
return unless path
|
||||
if state?
|
||||
localStorage[path] = JSON.stringify(state)
|
||||
else
|
||||
delete localStorage[path]
|
||||
|
||||
@@ -94,7 +94,7 @@ class RootView extends View
|
||||
delete @extensions[extension.name]
|
||||
|
||||
deactivate: ->
|
||||
# atom.rootViewStates[$windowNumber] = JSON.stringify(@serialize()) # TODO: Reinstate
|
||||
atom.setRootViewStateForPath(@project.getPath(), @serialize())
|
||||
@deactivateExtension(extension) for name, extension of @extensions
|
||||
@remove()
|
||||
|
||||
|
||||
@@ -25,14 +25,12 @@ windowAdditions =
|
||||
@shutdown()
|
||||
false
|
||||
$(window).focus()
|
||||
# atom.windowOpened this # TODO: Reinstate this!
|
||||
|
||||
shutdown: ->
|
||||
@rootView.deactivate()
|
||||
$(window).unbind('focus')
|
||||
$(window).unbind('blur')
|
||||
$(window).off('before')
|
||||
# atom.windowClosed this # TODO: Reinstate this!
|
||||
|
||||
setUpKeymap: ->
|
||||
Keymap = require 'keymap'
|
||||
@@ -47,8 +45,8 @@ windowAdditions =
|
||||
# Note: RootView assigns itself on window on initialization so that
|
||||
# window.rootView is available when loading user configuration
|
||||
attachRootView: (pathToOpen) ->
|
||||
if rootViewState = atom.rootViewStates?[$windowNumber]
|
||||
RootView.deserialize(JSON.parse(rootViewState))
|
||||
if rootViewState = atom.getRootViewStateForPath(pathToOpen)
|
||||
RootView.deserialize(rootViewState)
|
||||
else
|
||||
new RootView(pathToOpen)
|
||||
@rootView.open() unless pathToOpen
|
||||
|
||||
Reference in New Issue
Block a user