Assign line and character measurements on model via presenter

This commit is contained in:
Nathan Sobo
2015-02-09 15:32:14 -07:00
parent 4f0e1997cf
commit 48195851d4
2 changed files with 4 additions and 5 deletions

View File

@@ -253,9 +253,7 @@ LinesComponent = React.createClass
{editor, presenter} = @props
presenter.setLineHeight(lineHeightInPixels)
editor.setLineHeightInPixels(lineHeightInPixels)
presenter.setBaseCharacterWidth(charWidth)
editor.setDefaultCharWidth(charWidth)
remeasureCharacterWidths: ->
return unless @props.presenter.hasRequiredMeasurements()
@@ -312,7 +310,6 @@ LinesComponent = React.createClass
rangeForMeasurement.setStart(textNode, i)
rangeForMeasurement.setEnd(textNode, i + charLength)
charWidth = rangeForMeasurement.getBoundingClientRect().width
editor.setScopedCharWidth(scopes, char, charWidth)
@props.presenter.setScopedCharacterWidth(scopes, char, charWidth)
charIndex += charLength

View File

@@ -537,6 +537,7 @@ class TextEditorPresenter
setLineHeight: (lineHeight) ->
unless @lineHeight is lineHeight
@lineHeight = lineHeight
@model.setLineHeightInPixels(lineHeight)
@updateHeightState()
@updateVerticalScrollState()
@updateDecorations()
@@ -574,8 +575,9 @@ class TextEditorPresenter
@batchingCharacterMeasurement = false
@characterWidthsChanged() if oldChangeCount isnt @scopedCharacterWidthsChangeCount
setScopedCharacterWidth: (scopeNames, char, width) ->
@getScopedCharacterWidths(scopeNames)[char] = width
setScopedCharacterWidth: (scopeNames, character, width) ->
@getScopedCharacterWidths(scopeNames)[character] = width
@model.setScopedCharWidth(scopeNames, character, width)
@scopedCharacterWidthsChangeCount++
@characterWidthsChanged() unless @batchingCharacterMeasurement