Rework Buffer's 'contents-modified' event

This event now fires whenever the content of the buffer changes (after 
a rate-limiting delay) with a single boolean indicating the modified
status of the buffer. There's now a separate event called
'modified-status-changed' to indicate events that change the boolean
value of the isModified method, so we don't need to fire
'contents-modified' when the underlying file is deleted for instance.
This commit is contained in:
Nathan Sobo
2013-02-28 08:35:32 -07:00
committed by probablycorey
parent a1dc2cfc2d
commit 298a963148
4 changed files with 24 additions and 56 deletions

View File

@@ -70,7 +70,6 @@ class Buffer
@file.on "removed", =>
@updateCachedDiskContents()
@trigger "modified-status-changed", @isModified()
@trigger "contents-modified", {differsFromDisk: true}
@file.on "moved", =>
@trigger "path-changed", this
@@ -427,15 +426,15 @@ class Buffer
return unless path
git?.checkoutHead(path)
scheduleModifiedStatusChangedEvent: ->
scheduleModifiedEvents: ->
clearTimeout(@stoppedChangingTimeout) if @stoppedChangingTimeout
stoppedChangingCallback = =>
@stoppedChangingTimeout = null
modifiedStatus = @isModified()
@trigger 'contents-modified', modifiedStatus
unless modifiedStatus is @previousModifiedStatus
@previousModifiedStatus = modifiedStatus
@trigger 'modified-status-changed', modifiedStatus
@trigger 'contents-modified', {differsFromDisk: @isModified()}
@stoppedChangingTimeout = setTimeout(stoppedChangingCallback, @stoppedChangingDelay)
fileExists: ->