       @updateEndRow()
 
   constrainScrollTop: (scrollTop) ->
+    return scrollTop unless scrollTop? and @scrollHeight? and @clientHeight?
+
     if @hasRequiredMeasurements()
       Math.max(0, Math.min(scrollTop, @scrollHeight - @clientHeight))
     else

    @characterWidthsChanged() unless @batchingCharacterMeasurement

  characterWidthsChanged: ->
    @updateContentDimensions(false, true)

    @updateHorizontalScrollState()
    @updateContentState()

      @scrollHeight = scrollHeight
      @updateScrollTop()

  updateContentDimensions: ->
    return unless @lineHeight? and @baseCharacterWidth?

    oldContentHeight = @contentHeight
    @contentHeight = @lineHeight * @model.getScreenLineCount()

    oldContentWidth = @contentWidth
    @contentWidth = @pixelPositionForScreenPosition([@model.getLongestScreenRow(), Infinity]).left
    @contentWidth += 1 unless @model.isSoftWrapped() # account for cursor width

    if @contentHeight isnt oldContentHeight
      @updateHeight()
      @updateScrollbarDimensions()
      @updateScrollHeight()

    if @contentWidth isnt oldContentWidth
      @updateScrollbarDimensions()
      @updateScrollWidth()

  updateClientHeight: ->
    return unless @height? and @horizontalScrollbarHeight?

    clientHeight = @height - @horizontalScrollbarHeight
    unless @clientHeight is clientHeight
      @clientHeight = clientHeight
