Add Buffer.reload()

This commit is contained in:
Corey Johnson 2012-07-16 16:12:09 -07:00
parent 611eb93219
commit 5914b6cc2a
2 changed files with 16 additions and 0 deletions

View File

@ -299,6 +299,17 @@ describe 'Buffer', ->
buffer = new Buffer
expect(-> buffer.save()).toThrow()
describe "reload()", ->
it "loads text from disk are sets @modified and @modifiedOnDisk to false", ->
buffer.modified = true
buffer.modifiedOnDisk = true
buffer.setText("abc")
buffer.reload()
expect(buffer.modifed).toBeFalsy()
expect(buffer.modifiedOnDisk).toBeFalsy()
expect(buffer.getText()).toBe(fileContents)
describe ".saveAs(path)", ->
filePath = null

View File

@ -33,6 +33,11 @@ class Buffer
destroy: ->
@file?.off()
reload: ->
@setText(fs.read(@file.getPath()))
@modified = false
@modifiedOnDisk = false
getPath: ->
@file?.getPath()