diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index d6bddd95d..725c65b2d 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -90,6 +90,14 @@ describe "EditorComponent", -> expect(component.lineNodeForScreenRow(3).offsetTop).toBe 3 * lineHeightInPixels expect(component.lineNodeForScreenRow(4).offsetTop).toBe 4 * lineHeightInPixels + it "renders the .lines div at the full height of the editor if there aren't enough lines to scroll vertically", -> + editor.setText('') + node.style.height = '300px' + component.measureHeightAndWidth() + + linesNode = node.querySelector('.lines') + expect(linesNode.offsetHeight).toBe 300 + describe "when showInvisibles is enabled", -> invisibles = null diff --git a/src/editor-component.coffee b/src/editor-component.coffee index bf5904d53..d2971fb53 100644 --- a/src/editor-component.coffee +++ b/src/editor-component.coffee @@ -42,6 +42,7 @@ EditorComponent = React.createClass scrollWidth = editor.getScrollWidth() scrollTop = editor.getScrollTop() scrollLeft = editor.getScrollLeft() + scrollViewHeight = editor.getHeight() lineHeightInPixels = editor.getLineHeight() horizontalScrollbarHeight = editor.getHorizontalScrollbarHeight() verticalScrollbarWidth = editor.getVerticalScrollbarWidth() @@ -64,7 +65,7 @@ EditorComponent = React.createClass scrollTop, scrollLeft, scrollHeight, scrollWidth, @scrollingVertically, @cursorsMoved, @selectionChanged, @selectionAdded, cursorBlinkPeriod, cursorBlinkResumeDelay, @onInputFocused, @onInputBlurred, @mouseWheelScreenRow, - invisibles + invisibles, scrollViewHeight } ScrollbarComponent diff --git a/src/editor-scroll-view-component.coffee b/src/editor-scroll-view-component.coffee index 81b37ce8b..2f6b3a55d 100644 --- a/src/editor-scroll-view-component.coffee +++ b/src/editor-scroll-view-component.coffee @@ -17,7 +17,7 @@ EditorScrollViewComponent = React.createClass render: -> {editor, fontSize, fontFamily, lineHeight, showIndentGuide, invisibles} = @props - {renderedRowRange, pendingChanges, scrollTop, scrollLeft, scrollHeight, scrollWidth, scrollingVertically, mouseWheelScreenRow} = @props + {renderedRowRange, pendingChanges, scrollTop, scrollLeft, scrollHeight, scrollWidth, scrollViewHeight, scrollingVertically, mouseWheelScreenRow} = @props {selectionChanged, selectionAdded, cursorBlinkPeriod, cursorBlinkResumeDelay, cursorsMoved, onInputFocused, onInputBlurred} = @props if @isMounted() @@ -37,7 +37,8 @@ EditorScrollViewComponent = React.createClass LinesComponent { ref: 'lines', editor, fontSize, fontFamily, lineHeight, showIndentGuide, renderedRowRange, pendingChanges, scrollTop, scrollLeft, scrollingVertically, - selectionChanged, scrollHeight, scrollWidth, mouseWheelScreenRow, invisibles + selectionChanged, scrollHeight, scrollWidth, mouseWheelScreenRow, invisibles, + scrollViewHeight } componentDidMount: -> diff --git a/src/lines-component.coffee b/src/lines-component.coffee index 8b4dc29fa..419e25de3 100644 --- a/src/lines-component.coffee +++ b/src/lines-component.coffee @@ -15,9 +15,10 @@ LinesComponent = React.createClass render: -> if @isMounted() - {editor, scrollTop, scrollLeft, scrollHeight, scrollWidth, lineHeight} = @props + {editor, scrollTop, scrollLeft, scrollHeight, scrollWidth, lineHeight, scrollViewHeight} = @props + style = - height: scrollHeight + height: Math.max(scrollHeight, scrollViewHeight) width: scrollWidth WebkitTransform: "translate3d(#{-scrollLeft}px, #{-scrollTop}px, 0px)" @@ -35,7 +36,10 @@ LinesComponent = React.createClass shouldComponentUpdate: (newProps) -> return true if newProps.selectionChanged - return true unless isEqualForProperties(newProps, @props, 'renderedRowRange', 'fontSize', 'fontFamily', 'lineHeight', 'scrollTop', 'scrollLeft', 'showIndentGuide', 'scrollingVertically', 'invisibles') + return true unless isEqualForProperties(newProps, @props, + 'renderedRowRange', 'fontSize', 'fontFamily', 'lineHeight', 'scrollTop', 'scrollLeft', + 'showIndentGuide', 'scrollingVertically', 'invisibles', 'scrollViewHeight' + ) {renderedRowRange, pendingChanges} = newProps for change in pendingChanges