Vertical scrollbar height is updated when switching buffers

This commit is contained in:
Corey Johnson
2012-05-15 10:02:45 -07:00
parent facd7082d0
commit 6b3664a040
2 changed files with 11 additions and 1 deletions

View File

@@ -130,6 +130,14 @@ describe "Editor", ->
editor.setBuffer(buffer)
expect(otherBuffer.subscriptionCount()).toBe previousSubscriptionCount
it "resizes the vertical scrollbar based on the new buffer's height", ->
editor.attachToDom(heightInLines: 5)
originalHeight = editor.verticalScrollbar.prop('scrollHeight')
expect(originalHeight).toBeGreaterThan 0
editor.setBuffer(new Buffer(require.resolve('fixtures/sample.txt')))
expect(editor.verticalScrollbar.prop('scrollHeight')).toBeLessThan originalHeight
describe ".clipScreenPosition(point)", ->
it "selects the nearest valid position to the given point", ->
expect(editor.clipScreenPosition(row: 1000, column: 0)).toEqual(row: buffer.getLastRow(), column: buffer.lineForRow(buffer.getLastRow()).length)

View File

@@ -344,7 +344,9 @@ class Editor extends View
@buffer.on "path-change.editor#{@id}", => @trigger 'editor-path-change'
@renderer = new Renderer(@buffer, { maxLineLength: @calcMaxLineLength(), tabText: @tabText })
@renderLines() if @attached
if @attached
@prepareForVerticalScrolling()
@renderLines()
@loadEditSessionForBuffer(@buffer)