handle storage on the objective-c side.

This commit is contained in:
Corey Johnson
2011-11-04 17:43:15 -07:00
parent 9671e09be0
commit 750ede4f2c
8 changed files with 119 additions and 72 deletions

View File

@@ -29,36 +29,10 @@ windowAdditions =
@loadExtensions()
@loadKeyBindings()
@restoreEditorState()
@editor.restoreOpenBuffers()
storageKey: ->
"project:" + atomController.path
restoreEditorState: ->
storage = Storage.get @storageKey(), {}
@editor.addBuffer path for path in storage.openPaths ? []
@editor.focusBuffer storage.lastOpenedPath if storage.lastOpenedPath
# Remember what buffers were open and closed
Event.on "editor:bufferFocus", (e) =>
path = e.details
storage = Storage.get @storageKey(), {}
storage.lastOpenedPath = path.valueOf()
Storage.set @storageKey(), storage
Event.on "editor:bufferAdd", (e) =>
path = e.details
storage = Storage.get @storageKey(), {}
storage.openPaths ?= []
unless path.valueOf() in storage.openPaths
storage.openPaths.push path.valueOf()
Storage.set @storageKey(), storage
Event.on "editor:bufferRemove", (e) =>
path = e.details
storage = Storage.get @storageKey(), {}
storage.openPaths = (p for p in storage.openPaths when p != path)
Storage.set @storageKey(), storage
"window:" + atomController.path
loadExtensions: ->
extension.shutdown() for extension in @extensions