Don't emit a cursor-moved event when only the tail of the marker moves

This commit is contained in:
Kevin Sawicki & Nathan Sobo
2013-02-05 15:19:10 -07:00
parent 1d30605f7f
commit 240e893d33
2 changed files with 40 additions and 23 deletions

View File

@@ -13,18 +13,24 @@ class Cursor
constructor: ({@editSession, @marker}) ->
@editSession.observeMarker @marker, (e) =>
{oldHeadScreenPosition, newHeadScreenPosition} = e
{oldHeadBufferPosition, newHeadBufferPosition} = e
{bufferChanged} = e
return if oldHeadScreenPosition.isEqual(newHeadScreenPosition)
@setVisible(@selection.isEmpty())
@needsAutoscroll ?= @isLastCursor() and !e.bufferChanged
@needsAutoscroll ?= @isLastCursor() and !bufferChanged
event =
oldBufferPosition: e.oldHeadBufferPosition
oldScreenPosition: e.oldHeadScreenPosition
newBufferPosition: e.newHeadBufferPosition
newScreenPosition: e.newHeadScreenPosition
bufferChanged: e.bufferChanged
movedEvent =
oldBufferPosition: oldHeadBufferPosition
oldScreenPosition: oldHeadScreenPosition
newBufferPosition: newHeadBufferPosition
newScreenPosition: newHeadScreenPosition
bufferChanged: bufferChanged
@trigger 'moved', event
@editSession.trigger 'cursor-moved', event
@trigger 'moved', movedEvent
@editSession.trigger 'cursor-moved', movedEvent
@needsAutoscroll = true
destroy: ->