Update cursors as soon as all required measurements are assigned

This commit is contained in:
Nathan Sobo
2015-02-10 15:16:58 -07:00
parent 7d8f26ba61
commit 7f0110f49e
2 changed files with 12 additions and 1 deletions

View File

@@ -923,7 +923,7 @@ describe "TextEditorPresenter", ->
expect(stateForCursor(presenter, 4)).toBeUndefined()
it "is empty until all of the required measurements are assigned", ->
presenter = buildPresenter(explicitHeight: null, lineHeight: null, scrollTop: null, baseCharacterWidth: null)
presenter = buildPresenter(explicitHeight: null, lineHeight: null, scrollTop: null, baseCharacterWidth: null, horizontalScrollbarHeight: null)
expect(presenter.state.content.cursors).toEqual({})
presenter.setExplicitHeight(25)
@@ -936,6 +936,9 @@ describe "TextEditorPresenter", ->
expect(presenter.state.content.cursors).toEqual({})
presenter.setBaseCharacterWidth(8)
expect(presenter.state.content.cursors).toEqual({})
presenter.setHorizontalScrollbarHeight(10)
expect(presenter.state.content.cursors).not.toEqual({})
it "updates when ::scrollTop changes", ->

View File

@@ -483,23 +483,29 @@ class TextEditorPresenter
setScrollLeft: (scrollLeft) ->
scrollLeft = @constrainScrollLeft(scrollLeft)
unless @scrollLeft is scrollLeft
oldScrollLeft = @scrollLeft
@scrollLeft = scrollLeft
@model.setScrollLeft(scrollLeft)
@updateHorizontalScrollState()
@updateCursorsState() unless oldScrollLeft?
setHorizontalScrollbarHeight: (horizontalScrollbarHeight) ->
unless @horizontalScrollbarHeight is horizontalScrollbarHeight
oldHorizontalScrollbarHeight = @horizontalScrollbarHeight
@horizontalScrollbarHeight = horizontalScrollbarHeight
@model.setHorizontalScrollbarHeight(horizontalScrollbarHeight)
@updateScrollbarsState()
@updateVerticalScrollState()
@updateCursorsState() unless oldHorizontalScrollbarHeight?
setVerticalScrollbarWidth: (verticalScrollbarWidth) ->
unless @verticalScrollbarWidth is verticalScrollbarWidth
oldVerticalScrollbarWidth = @verticalScrollbarWidth
@verticalScrollbarWidth = verticalScrollbarWidth
@model.setVerticalScrollbarWidth(verticalScrollbarWidth)
@updateScrollbarsState()
@updateHorizontalScrollState()
@updateCursorsState() unless oldVerticalScrollbarWidth?
setAutoHeight: (autoHeight) ->
unless @autoHeight is autoHeight
@@ -522,6 +528,7 @@ class TextEditorPresenter
setContentFrameWidth: (contentFrameWidth) ->
unless @contentFrameWidth is contentFrameWidth
oldContentFrameWidth = @contentFrameWidth
@contentFrameWidth = contentFrameWidth
@model.setWidth(contentFrameWidth)
@updateVerticalScrollState()
@@ -530,6 +537,7 @@ class TextEditorPresenter
@updateContentState()
@updateDecorations()
@updateLinesState()
@updateCursorsState() unless oldContentFrameWidth?
setBackgroundColor: (backgroundColor) ->
unless @backgroundColor is backgroundColor