mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Decouple horizontal dimensions computation from vertical ones
The former needs measurement and, therefore, depends on the latter.
This commit is contained in:
@@ -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?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user