mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-08 08:07:32 +03:00
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:
parent
3150785db2
commit
dab8c5b53b
@ -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", ->
|
||||
|
@ -41,11 +41,13 @@ class Buffer
|
||||
@setPath(path)
|
||||
if initialText?
|
||||
@setText(initialText)
|
||||
@updateCachedDiskContents()
|
||||
else
|
||||
@reload()
|
||||
else
|
||||
@setText(initialText ? '')
|
||||
|
||||
|
||||
@undoManager = new UndoManager(this)
|
||||
|
||||
destroy: ->
|
||||
|
Loading…
Reference in New Issue
Block a user