diff --git a/package.json b/package.json index 6dc56fa54..bb1203df1 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "serializable": "^1", "space-pen": "3.4.6", "temp": "0.7.0", - "text-buffer": "^3.1.0", + "text-buffer": "^3.2.0", "theorist": "^1.0.2", "underscore-plus": "^1.5.1", "vm-compatibility-layer": "0.1.0" diff --git a/spec/git-spec.coffee b/spec/git-spec.coffee index b40f68182..2de1d2e16 100644 --- a/spec/git-spec.coffee +++ b/spec/git-spec.coffee @@ -253,10 +253,10 @@ describe "Git", -> statusHandler = jasmine.createSpy('statusHandler') atom.project.getRepo().on 'status-changed', statusHandler - editor.getBuffer().emit 'path-changed' + editor.getBuffer().emitter.emit 'did-change-path' expect(statusHandler.callCount).toBe 1 expect(statusHandler).toHaveBeenCalledWith editor.getPath(), 256 - editor.getBuffer().emit 'path-changed' + editor.getBuffer().emitter.emit 'did-change-path' expect(statusHandler.callCount).toBe 1 describe "when a project is deserialized", -> diff --git a/src/display-buffer-marker.coffee b/src/display-buffer-marker.coffee index e2324f6b7..7f868f24e 100644 --- a/src/display-buffer-marker.coffee +++ b/src/display-buffer-marker.coffee @@ -22,8 +22,8 @@ class DisplayBufferMarker @oldTailScreenPosition = @getTailScreenPosition() @wasValid = @isValid() - @subscribe @bufferMarker, 'destroyed', => @destroyed() - @subscribe @bufferMarker, 'changed', (event) => @notifyObservers(event) + @subscribe @bufferMarker.onDidDestroy => @destroyed() + @subscribe @bufferMarker.onDidChange (event) => @notifyObservers(event) copy: (attributes) -> @displayBuffer.getMarker(@bufferMarker.copy(attributes).id) diff --git a/src/display-buffer.coffee b/src/display-buffer.coffee index 5146f1816..6b345ab89 100644 --- a/src/display-buffer.coffee +++ b/src/display-buffer.coffee @@ -55,8 +55,8 @@ class DisplayBuffer extends Model @subscribe @tokenizedBuffer, 'grammar-changed', (grammar) => @emit 'grammar-changed', grammar @subscribe @tokenizedBuffer, 'tokenized', => @emit 'tokenized' @subscribe @tokenizedBuffer, 'changed', @handleTokenizedBufferChange - @subscribe @buffer, 'markers-updated', @handleBufferMarkersUpdated - @subscribe @buffer, 'marker-created', @handleBufferMarkerCreated + @subscribe @buffer.onDidUpdateMarkers @handleBufferMarkersUpdated + @subscribe @buffer.onDidCreateMarker @handleBufferMarkerCreated @subscribe @$softWrap, (softWrap) => @emit 'soft-wrap-changed', softWrap diff --git a/src/editor.coffee b/src/editor.coffee index 342d9cc0f..9f9d18da7 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -253,15 +253,15 @@ class Editor extends Model subscribeToBuffer: -> @buffer.retain() - @subscribe @buffer, "path-changed", => + @subscribe @buffer.onDidChangePath => unless atom.project.getPath()? atom.project.setPath(path.dirname(@getPath())) @emit "title-changed" @emit "path-changed" - @subscribe @buffer, "contents-modified", => @emit "contents-modified" - @subscribe @buffer, "contents-conflicted", => @emit "contents-conflicted" - @subscribe @buffer, "modified-status-changed", => @emit "modified-status-changed" - @subscribe @buffer, "destroyed", => @destroy() + @subscribe @buffer.onDidStopChanging => @emit "contents-modified" + @subscribe @buffer.onDidConflict => @emit "contents-conflicted" + @subscribe @buffer.onDidChangeModified => @emit "modified-status-changed" + @subscribe @buffer.onDidDestroy => @destroy() @preserveCursorPositionOnBufferReload() subscribeToDisplayBuffer: -> @@ -1821,9 +1821,9 @@ class Editor extends Model preserveCursorPositionOnBufferReload: -> cursorPosition = null - @subscribe @buffer, "will-reload", => + @subscribe @buffer.onWillReload => cursorPosition = @getCursorBufferPosition() - @subscribe @buffer, "reloaded", => + @subscribe @buffer.onDidReload => @setCursorBufferPosition(cursorPosition) if cursorPosition cursorPosition = null diff --git a/src/fold.coffee b/src/fold.coffee index 4b61d24af..617d590ce 100644 --- a/src/fold.coffee +++ b/src/fold.coffee @@ -14,8 +14,8 @@ class Fold @id = @marker.id @displayBuffer.foldsByMarkerId[@marker.id] = this @updateDisplayBuffer() - @marker.on 'destroyed', => @destroyed() - @marker.on 'changed', ({isValid}) => @destroy() unless isValid + @marker.onDidDestroy => @destroyed() + @marker.onDidChange ({isValid}) => @destroy() unless isValid # Returns whether this fold is contained within another fold isInsideLargerFold: -> diff --git a/src/git.coffee b/src/git.coffee index 7cf4014a9..2c9cc7550 100644 --- a/src/git.coffee +++ b/src/git.coffee @@ -88,10 +88,14 @@ class Git # Subscribes to buffer events. subscribeToBuffer: (buffer) -> - @subscribe buffer, 'saved reloaded path-changed', => + getBufferPathStatus = => if path = buffer.getPath() @getPathStatus(path) - @subscribe buffer, 'destroyed', => @unsubscribe(buffer) + + @subscribe buffer.onDidSave(getBufferPathStatus) + @subscribe buffer.onDidReload(getBufferPathStatus) + @subscribe buffer.onDidChangePath(getBufferPathStatus) + @subscribe buffer.onDidDestroy => @unsubscribe(buffer) # Subscribes to editor view event. checkoutHeadForEditor: (editor) -> diff --git a/src/project.coffee b/src/project.coffee index bf2adf2c3..a34a442a5 100644 --- a/src/project.coffee +++ b/src/project.coffee @@ -49,7 +49,7 @@ class Project extends Model for buffer in @buffers do (buffer) => - buffer.once 'destroyed', => @removeBuffer(buffer) + buffer.onDidDestroy => @removeBuffer(buffer) @setPath(path) @@ -216,11 +216,11 @@ class Project extends Model addBuffer: (buffer, options={}) -> @addBufferAtIndex(buffer, @buffers.length, options) - buffer.once 'destroyed', => @removeBuffer(buffer) + buffer.onDidDestroy => @removeBuffer(buffer) addBufferAtIndex: (buffer, index, options={}) -> @buffers.splice(index, 0, buffer) - buffer.once 'destroyed', => @removeBuffer(buffer) + buffer.onDidDestroy => @removeBuffer(buffer) @emit 'buffer-created', buffer buffer diff --git a/src/select-list-view.coffee b/src/select-list-view.coffee index b9227df18..ae5ffdc93 100644 --- a/src/select-list-view.coffee +++ b/src/select-list-view.coffee @@ -51,7 +51,7 @@ class SelectListView extends View # This method can be overridden by subclasses but `super` should always # be called. initialize: -> - @filterEditorView.getEditor().getBuffer().on 'changed', => + @filterEditorView.getEditor().getBuffer().onDidChange => @schedulePopulateList() @filterEditorView.hiddenInput.on 'focusout', => @cancel() unless @cancelling diff --git a/src/tokenized-buffer.coffee b/src/tokenized-buffer.coffee index 79dcba5f7..0ef877869 100644 --- a/src/tokenized-buffer.coffee +++ b/src/tokenized-buffer.coffee @@ -30,10 +30,8 @@ class TokenizedBuffer extends Model @setGrammar(grammar, newScore) if newScore > @currentGrammarScore @on 'grammar-changed grammar-updated', => @retokenizeLines() - @subscribe @buffer, "changed", (e) => @handleBufferChange(e) - @subscribe @buffer, "path-changed", => - @bufferPath = @buffer.getPath() - @reloadGrammar() + @subscribe @buffer.onDidChange (e) => @handleBufferChange(e) + @subscribe @buffer.onDidChangePath (@bufferPath) => @reloadGrammar() @subscribe @$tabLength.changes, (tabLength) => @retokenizeLines()