mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Project doesn't serialize non-modified buffers that don't exist on disk
This commit is contained in:
@@ -26,6 +26,18 @@ describe "Project", ->
|
||||
expect(deserializedProject.getBuffers().length).toBe 0
|
||||
expect(atom.project.getBuffers().length).toBe 0
|
||||
|
||||
it "destroys non-existent non-modified buffers and does not include them in the serialized state", ->
|
||||
nonExistentNonModified = atom.project.openSync("non-existent-non-modified.txt")
|
||||
nonExistentModified = atom.project.openSync("non-existent-modified.txt")
|
||||
nonExistentModified.setText("I am modified")
|
||||
expect(atom.project.getBuffers().length).toBe 2
|
||||
|
||||
atom.project.getState().serializeForPersistence()
|
||||
deserializedProject = atom.replicate().get('project')
|
||||
|
||||
expect(deserializedProject.getBuffers().length).toBe 1
|
||||
expect(atom.project.getBuffers().length).toBe 1
|
||||
|
||||
it "listens for destroyed events on deserialized buffers and removes them when they are destroyed", ->
|
||||
atom.project.openSync('a')
|
||||
expect(atom.project.getBuffers().length).toBe 1
|
||||
|
||||
@@ -43,6 +43,7 @@ class Project extends telepath.Model
|
||||
# Private: Called by telepath.
|
||||
beforePersistence: ->
|
||||
@destroyUnretainedBuffers()
|
||||
@destroyNonExistentNonModified()
|
||||
|
||||
# Public: Register an opener for project files.
|
||||
#
|
||||
@@ -77,6 +78,9 @@ class Project extends telepath.Model
|
||||
destroyUnretainedBuffers: ->
|
||||
buffer.destroy() for buffer in @getBuffers() when not buffer.isRetained()
|
||||
|
||||
destroyNonExistentNonModified: ->
|
||||
buffer.destroy() for buffer in @getBuffers() when not buffer.isModified() and not buffer.file.exists()
|
||||
|
||||
# Public: Returns the {Git} repository if available.
|
||||
getRepo: -> @repo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user