mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-11 04:48:44 +03:00
Add Buffer.reload()
This commit is contained in:
parent
611eb93219
commit
5914b6cc2a
@ -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
|
||||
|
||||
|
@ -33,6 +33,11 @@ class Buffer
|
||||
destroy: ->
|
||||
@file?.off()
|
||||
|
||||
reload: ->
|
||||
@setText(fs.read(@file.getPath()))
|
||||
@modified = false
|
||||
@modifiedOnDisk = false
|
||||
|
||||
getPath: ->
|
||||
@file?.getPath()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user