Saving a buffer sets its modified flag to false

This commit is contained in:
Corey Johnson 2012-06-12 11:29:38 -07:00
parent 8ab167fd00
commit 1fb8852fc3
2 changed files with 13 additions and 1 deletions

View File

@ -57,6 +57,17 @@ describe 'Buffer', ->
buffer.insert([0,0], "hi")
expect(buffer.isModified()).toBe true
it "returns false after modified buffer is saved", ->
filePath = "/tmp/atom-tmp-file"
buffer = new Buffer(filePath)
expect(buffer.isModified()).toBe false
buffer.insert([0,0], "hi")
expect(buffer.isModified()).toBe true
buffer.save()
expect(buffer.isModified()).toBe false
describe '.deserialize(state, project)', ->
project = null

View File

@ -161,9 +161,10 @@ class Buffer
@undoManager.redo()
save: ->
if not @getPath() then throw new Error("Tried to save buffer with no file path")
if not @getPath() then throw new Error("Can't save buffer with no file path")
@trigger 'before-save'
fs.write @getPath(), @getText()
@modified = false
@trigger 'after-save'
saveAs: (path) ->