From 6b3664a0407025336d4e124d9455ad67daebf4a5 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 15 May 2012 10:02:45 -0700 Subject: [PATCH] Vertical scrollbar height is updated when switching buffers --- spec/app/editor-spec.coffee | 8 ++++++++ src/app/editor.coffee | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 2bd793ed0..2c4d5ecea 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -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) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index a195c4634..782935bc0 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -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)