🐎 Batch cursor updates

This commit is contained in:
Antonio Scandurra
2015-08-19 11:32:16 +02:00
parent f31dc03e1d
commit ea391d017d

View File

@@ -410,10 +410,7 @@ class TextEditorPresenter
@updateCursorState(cursor) for cursor in @model.cursors # using property directly to avoid allocation
return
updateCursorState: (cursor, destroyOnly = false) ->
delete @state.content.cursors[cursor.id]
return if destroyOnly
updateCursorState: (cursor) ->
return unless @startRow? and @endRow? and @hasPixelRectRequirements() and @baseCharacterWidth?
return unless cursor.isVisible() and @startRow <= cursor.getScreenRow() < @endRow
@@ -1365,20 +1362,20 @@ class TextEditorPresenter
observeCursor: (cursor) ->
didChangePositionDisposable = cursor.onDidChangePosition =>
@shouldUpdateHiddenInputState = true if cursor.isLastCursor()
@shouldUpdateCursorsState = true
@pauseCursorBlinking()
@updateCursorState(cursor)
@emitDidUpdateState()
didChangeVisibilityDisposable = cursor.onDidChangeVisibility =>
@updateCursorState(cursor)
@shouldUpdateCursorsState = true
didDestroyDisposable = cursor.onDidDestroy =>
@disposables.remove(didChangePositionDisposable)
@disposables.remove(didChangeVisibilityDisposable)
@disposables.remove(didDestroyDisposable)
@shouldUpdateHiddenInputState = true
@updateCursorState(cursor, true)
@shouldUpdateCursorsState = true
@emitDidUpdateState()
@@ -1389,8 +1386,9 @@ class TextEditorPresenter
didAddCursor: (cursor) ->
@observeCursor(cursor)
@shouldUpdateHiddenInputState = true
@shouldUpdateCursorsState = true
@pauseCursorBlinking()
@updateCursorState(cursor)
@emitDidUpdateState()
startBlinkingCursors: ->