mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
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:
committed by
probablycorey
parent
a1dc2cfc2d
commit
298a963148
@@ -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: ->
|
||||
|
||||
Reference in New Issue
Block a user