Cache hidden/visible state of cursor to avoid extra DOM hit when updating its appearance

This commit is contained in:
Nathan Sobo
2012-05-30 10:51:27 -06:00
parent b1573438a7
commit c291cd1bb3

View File

@@ -12,6 +12,7 @@ class Cursor extends View
anchor: null
editor: null
wordRegex: /(\w+)|([^\w\s]+)/g
hidden: false
initialize: ({editor, screenPosition} = {}) ->
@editor = editor
@@ -178,8 +179,10 @@ class Cursor extends View
@editor.scrollTo(pixelPosition)
if @editor.isFoldedAtScreenRow(screenPosition.row)
@hide()
@hide() unless @hidden
@hidden = true
else
@show()
@show() if @hidden
@hidden = false
@selection.updateAppearance()