Upgrade to telepath 0.61.0

This version adds a bunch of reactive primitives and ensures we destroy
documents when they are no longer referenced.
This commit is contained in:
Nathan Sobo
2013-12-06 12:38:46 -08:00
parent db1768a9c7
commit b61654b52f
8 changed files with 29 additions and 31 deletions

View File

@@ -204,6 +204,7 @@ class Atom
@workspaceView.remove()
@project.destroy()
@windowEventHandler?.unsubscribe()
@windowState = null
# Set up the default event handlers and menus for a non-editor window.
#
@@ -398,8 +399,8 @@ class Atom
windowState.set(keyPath, value)
windowState
# Private:
loadWindowState: ->
# Private
loadSerializedWindowState: ->
if windowStatePath = @getWindowStatePath()
if fs.existsSync(windowStatePath)
try
@@ -414,7 +415,10 @@ class Atom
catch error
console.warn "Error parsing window state: #{windowStatePath}", error.stack, error
doc = Document.deserialize(documentState) if documentState?
# Private:
loadWindowState: ->
serializedWindowState = @loadSerializedWindowState()
doc = Document.deserialize(serializedWindowState) if serializedWindowState?
doc ?= Document.create()
doc.registerModelClasses(require('./text-buffer'), require('./project'))
# TODO: Remove this when everything is using telepath models

View File

@@ -32,7 +32,7 @@ class Project extends telepath.Model
path.join(atom.config.get('core.projectHome'), repoName)
# Private: Called by telepath.
attached: ->
created: ->
for buffer in @buffers.getValues()
buffer.once 'destroyed', (buffer) => @removeBuffer(buffer)
@@ -62,7 +62,7 @@ class Project extends telepath.Model
unregisterOpener: (opener) -> _.remove(@openers, opener)
# Private:
destroy: ->
destroyed: ->
editor.destroy() for editor in @getEditors()
buffer.release() for buffer in @getBuffers()
@destroyRepo()

View File

@@ -6,7 +6,6 @@ class SiteShim
setRootDocument: (@document) ->
@id = @document.siteId
@document.set('looseDocuments', [])
createDocument: (values) ->
@document.get('looseDocuments').push(values)
@document.create({values})

View File

@@ -38,7 +38,7 @@ class TextBuffer extends telepath.Model
@loadWhenAttached = @getState()?
# Private: Called by telepath.
attached: ->
created: ->
@loaded = false
@useSerializedText = @modifiedWhenLastPersisted != false
@@ -63,12 +63,13 @@ class TextBuffer extends telepath.Model
@updateCachedDiskContents().then => @finishLoading()
finishLoading: ->
@loaded = true
if @useSerializedText and @digestWhenLastPersisted is @file?.getDigest()
@emitModifiedStatusChanged(true)
else
@reload()
@text.clearUndoStack()
if @isAlive()
@loaded = true
if @useSerializedText and @digestWhenLastPersisted is @file?.getDigest()
@emitModifiedStatusChanged(true)
else
@reload()
@text.clearUndoStack()
this
### Internal ###