Update scrollTop to valid position when scrollbar disappears

This commit is contained in:
Nathan Sobo
2014-04-23 14:13:19 -06:00
parent c4be32a5dd
commit d9ba9262bf
2 changed files with 2 additions and 2 deletions

View File

@@ -539,10 +539,9 @@ describe "EditorComponent", ->
topOfHorizontalScrollbar = horizontalScrollbarNode.getBoundingClientRect().top
expect(bottomOfLastLine).toBe topOfHorizontalScrollbar
# Render no space below the last line when there's no horizontal scrollbar
# Scroll so there's no space below the last line when the horizontal scrollbar disappears
node.style.width = 100 * charWidth + 'px'
component.measureHeightAndWidth()
editor.setScrollBottom(editor.getScrollHeight())
lastLineNode = last(node.querySelectorAll('.line'))
bottomOfLastLine = lastLineNode.getBoundingClientRect().bottom
bottomOfEditor = node.getBoundingClientRect().bottom

View File

@@ -130,6 +130,7 @@ class DisplayBuffer extends Model
oldWidth = @width
@width = newWidth
@updateWrappedScreenLines() if newWidth isnt oldWidth and @softWrap
@setScrollTop(@getScrollTop()) # Ensure scrollTop is still valid in case horizontal scrollbar disappeared
@width
getScrollTop: -> @scrollTop