Buffer stores a is modified on disk flag

This commit is contained in:
Corey Johnson
2012-07-16 16:11:52 -07:00
parent 5f1e441538
commit 611eb93219
2 changed files with 23 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ class Buffer
@idCounter = 1
undoManager: null
modified: null
modifiedOnDisk: null
lines: null
file: null
@@ -41,7 +42,9 @@ class Buffer
@file?.off()
@file = new File(path)
@file.on "contents-change", =>
unless @isModified()
if @isModified()
@modifiedOnDisk = true
else
@setText(fs.read(@file.getPath()))
@modified = false
@trigger "path-change", this
@@ -167,9 +170,13 @@ class Buffer
fs.write path, @getText()
@file?.updateMd5()
@modified = false
@modifiedOnDisk = false
@setPath(path)
@trigger 'after-save'
isModifiedOnDisk: ->
@modifiedOnDisk
isModified: ->
@modified