Decouple horizontal dimensions computation from vertical ones

The former needs measurement and, therefore, depends on the latter.
This commit is contained in:
Antonio Scandurra
2015-09-15 17:30:42 +02:00
parent 578b157da0
commit 1cdc7ae5a0

View File

@@ -67,12 +67,14 @@ class TextEditorPresenter
getState: ->
@updating = true
@updateContentDimensions()
@updateVerticalDimensions()
@updateScrollbarDimensions()
@updateStartRow()
@updateEndRow()
@updateCommonGutterState()
@updateHorizontalDimensions()
@updateFocusedState() if @shouldUpdateFocusedState
@updateHeightState() if @shouldUpdateHeightState
@updateVerticalScrollState() if @shouldUpdateVerticalScrollState
@@ -112,7 +114,7 @@ class TextEditorPresenter
observeModel: ->
@disposables.add @model.onDidChange =>
@updateContentDimensions()
@updateVerticalDimensions()
@shouldUpdateHeightState = true
@shouldUpdateVerticalScrollState = true
@@ -671,11 +673,17 @@ class TextEditorPresenter
@scrollHeight = scrollHeight
@updateScrollTop()
updateContentDimensions: ->
updateVerticalDimensions: ->
if @lineHeight?
oldContentHeight = @contentHeight
@contentHeight = @lineHeight * @model.getScreenLineCount()
if @contentHeight isnt oldContentHeight
@updateHeight()
@updateScrollbarDimensions()
@updateScrollHeight()
updateHorizontalDimensions: ->
if @baseCharacterWidth?
oldContentWidth = @contentWidth
clip = @model.tokenizedLineForScreenRow(@model.getLongestScreenRow())?.isSoftWrapped()
@@ -683,15 +691,14 @@ class TextEditorPresenter
@contentWidth += @scrollLeft
@contentWidth += 1 unless @model.isSoftWrapped() # account for cursor width
if @contentHeight isnt oldContentHeight
@updateHeight()
@updateScrollbarDimensions()
@updateScrollHeight()
if @contentWidth isnt oldContentWidth
@updateScrollbarDimensions()
@updateScrollWidth()
updateContentDimensions: ->
@updateVerticalDimensions()
@updateHorizontalDimensions()
updateClientHeight: ->
return unless @height? and @horizontalScrollbarHeight?