Update TextEditorPresenter with scoped character widths in component

Signed-off-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
Esse commit está contido em:
Nathan Sobo
2015-01-20 15:28:33 -07:00
commit 3ec4b632ba
2 arquivos alterados com 7 adições e 5 exclusões
+6 -4
Ver Arquivo
@@ -52,7 +52,7 @@ LinesComponent = React.createClass
"translate(#{-scrollLeft}px, #{-scrollTop}px)"
componentWillMount: ->
@measuredLines = new WeakSet
@measuredLines = new Set
@lineNodesByLineId = {}
@screenRowsByLineId = {}
@lineIdsByScreenRow = {}
@@ -291,8 +291,8 @@ LinesComponent = React.createClass
node = @getDOMNode()
editor.batchCharacterMeasurement =>
for id, lineState in @newState
unless @measuredLines.has(tokenizedLine)
for id, lineState of @oldState
unless @measuredLines.has(id)
lineNode = @lineNodesByLineId[id]
@measureCharactersInLine(lineState, lineNode)
return
@@ -337,11 +337,13 @@ LinesComponent = React.createClass
rangeForMeasurement.setEnd(textNode, i + charLength)
charWidth = rangeForMeasurement.getBoundingClientRect().width
editor.setScopedCharWidth(scopes, char, charWidth)
@props.presenter.setScopedCharWidth(scopes, char, charWidth)
charIndex += charLength
@measuredLines.add(tokenizedLine)
@measuredLines.add(tokenizedLine.id)
clearScopedCharWidths: ->
@measuredLines.clear()
@props.editor.clearScopedCharWidths()
@props.presenter.clearScopedCharWidths()
+1 -1
Ver Arquivo
@@ -227,7 +227,7 @@ TextEditorComponent = React.createClass
@updatesPaused = false
{editor, lineOverdrawMargin} = @props
@presenter = new TextEditorPresenter
@presenter ?= new TextEditorPresenter
model: editor
clientHeight: editor.getHeight()
clientWidth: editor.getWidth()