mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Remove ‘cursors-moved’ event
It event was not document only being used in EditorComponent. Due to our batching strategy, it’s fine to respond to individual ::onDidMoveCursor events.
This commit is contained in:
@@ -174,21 +174,6 @@ describe "Editor", ->
|
||||
editor.moveDown()
|
||||
expect(editor.getCursorBufferPosition()).toEqual [1, 1]
|
||||
|
||||
it "emits a single 'cursors-moved' event for all moved cursors", ->
|
||||
editor.on 'cursors-moved', cursorsMovedHandler = jasmine.createSpy("cursorsMovedHandler")
|
||||
|
||||
editor.moveDown()
|
||||
expect(cursorsMovedHandler.callCount).toBe 1
|
||||
|
||||
cursorsMovedHandler.reset()
|
||||
editor.addCursorAtScreenPosition([3, 0])
|
||||
editor.moveDown()
|
||||
expect(cursorsMovedHandler.callCount).toBe 1
|
||||
|
||||
cursorsMovedHandler.reset()
|
||||
editor.getLastCursor().moveDown()
|
||||
expect(cursorsMovedHandler.callCount).toBe 1
|
||||
|
||||
describe ".setCursorScreenPosition(screenPosition)", ->
|
||||
it "clears a goal column established by vertical movement", ->
|
||||
# set a goal column by moving down
|
||||
|
||||
@@ -31,7 +31,7 @@ EditorComponent = React.createClass
|
||||
updateRequested: false
|
||||
updatesPaused: false
|
||||
updateRequestedWhilePaused: false
|
||||
cursorsMoved: false
|
||||
cursorMoved: false
|
||||
selectionChanged: false
|
||||
selectionAdded: false
|
||||
scrollingVertically: false
|
||||
@@ -196,16 +196,16 @@ EditorComponent = React.createClass
|
||||
@props.editor.setMini(newProps.mini)
|
||||
|
||||
componentDidUpdate: (prevProps, prevState) ->
|
||||
cursorsMoved = @cursorsMoved
|
||||
cursorMoved = @cursorMoved
|
||||
selectionChanged = @selectionChanged
|
||||
@pendingChanges.length = 0
|
||||
@cursorsMoved = false
|
||||
@cursorMoved = false
|
||||
@selectionChanged = false
|
||||
|
||||
if @props.editor.isAlive()
|
||||
@updateParentViewFocusedClassIfNeeded(prevState)
|
||||
@updateParentViewMiniClassIfNeeded(prevState)
|
||||
@props.parentView.trigger 'cursor:moved' if cursorsMoved
|
||||
@props.parentView.trigger 'cursor:moved' if cursorMoved
|
||||
@props.parentView.trigger 'selection:changed' if selectionChanged
|
||||
@props.parentView.trigger 'editor:display-updated'
|
||||
|
||||
@@ -346,7 +346,7 @@ EditorComponent = React.createClass
|
||||
observeEditor: ->
|
||||
{editor} = @props
|
||||
@subscribe editor, 'screen-lines-changed', @onScreenLinesChanged
|
||||
@subscribe editor, 'cursors-moved', @onCursorsMoved
|
||||
@subscribe editor.onDidMoveCursor(@onCursorMoved)
|
||||
@subscribe editor, 'selection-removed selection-screen-range-changed', @onSelectionChanged
|
||||
@subscribe editor, 'selection-added', @onSelectionAdded
|
||||
@subscribe editor, 'decoration-added', @onDecorationChanged
|
||||
@@ -749,8 +749,8 @@ EditorComponent = React.createClass
|
||||
|
||||
onStoppedScrollingAfterDelay: null # created lazily
|
||||
|
||||
onCursorsMoved: ->
|
||||
@cursorsMoved = true
|
||||
onCursorMoved: ->
|
||||
@cursorMoved = true
|
||||
@requestUpdate()
|
||||
|
||||
onDecorationChanged: ->
|
||||
|
||||
@@ -1850,16 +1850,12 @@ class Editor extends Model
|
||||
@emit 'cursor-removed', cursor
|
||||
|
||||
moveCursors: (fn) ->
|
||||
@movingCursors = true
|
||||
fn(cursor) for cursor in @getCursors()
|
||||
@mergeCursors()
|
||||
@movingCursors = false
|
||||
@emit 'cursors-moved'
|
||||
|
||||
cursorMoved: (cursor, event) ->
|
||||
@emit 'cursor-moved', event
|
||||
@emitter.emit 'did-move-cursor', _.extend({cursor}, event)
|
||||
@emit 'cursors-moved' unless @movingCursors
|
||||
|
||||
# Merge cursors that have the same screen position
|
||||
mergeCursors: ->
|
||||
|
||||
Reference in New Issue
Block a user