Assign cachedDiskContents when unsaved buffer is deserialized

This allows the buffer to return to an "unmodified" state if the
unsaved changes are reversed.
This commit is contained in:
Nathan Sobo 2013-04-02 15:12:33 -06:00
parent 3150785db2
commit dab8c5b53b
2 changed files with 5 additions and 0 deletions

View File

@ -1251,11 +1251,14 @@ describe 'Buffer', ->
describe "when the serialized buffer had unsaved changes", ->
it "restores the previous unsaved state of the buffer", ->
path = buffer.getPath()
previousText = buffer.getText()
buffer.setText("abc")
reloadBuffer()
expect(serializedState.text).toBe "abc"
expect(buffer.getPath()).toBe(path)
expect(buffer.getText()).toBe("abc")
buffer.setText(previousText)
expect(buffer.isModified()).toBeFalsy()
describe "when the serialized buffer was unsaved and had no path", ->
it "restores the previous unsaved state of the buffer", ->

View File

@ -41,11 +41,13 @@ class Buffer
@setPath(path)
if initialText?
@setText(initialText)
@updateCachedDiskContents()
else
@reload()
else
@setText(initialText ? '')
@undoManager = new UndoManager(this)
destroy: ->