diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index b1666b857..0c0f76a58 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -317,7 +317,7 @@ describe "Editor", -> expect(editor.charWidth).toBeGreaterThan charWidthBefore expect(editor.getCursorView().position()).toEqual { top: 5 * editor.lineHeight, left: 6 * editor.charWidth } expect(editor.renderedLines.outerHeight()).toBe buffer.getLineCount() * editor.lineHeight - expect(editor.verticalScrollbarContent.height()).toBe buffer.getLineCount() * editor.lineHeight + expect(editor.verticalScrollbarContent.height()).toBe (buffer.getLineCount() + editor.bottomPaddingInLines) * editor.lineHeight newEditor = new Editor(editor.activeEditSession.copy()) editor.remove() @@ -1297,6 +1297,7 @@ describe "Editor", -> describe "when lines are removed", -> beforeEach -> + editor.bottomPaddingInLines = 0 editor.attachToDom(heightInLines: 5) it "sets the rendered screen line's width to either the max line length or the scollView's width (whichever is greater)", -> @@ -1391,6 +1392,7 @@ describe "Editor", -> describe "when autoscrolling at the end of the document", -> it "renders lines properly", -> editor.edit(project.buildEditSession('two-hundred.txt')) + editor.bottomPaddingInLines = 0 editor.attachToDom(heightInLines: 5.5) expect(editor.renderedLines.find('.line').length).toBe 8 diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 9defac0f1..f8f47ba2f 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -64,6 +64,7 @@ class Editor extends View newCursors: null newSelections: null redrawOnReattach: false + bottomPaddingInLines: 10 # Public: The constructor for setting up an `Editor` instance. # @@ -1280,7 +1281,10 @@ class Editor extends View @overlayer.height(height) @layerHeight = height - @verticalScrollbarContent.height(height) + bottomPaddingInLines = if @mini then 0 else @bottomPaddingInLines + heightWithPadding = height + (@lineHeight * bottomPaddingInLines) + @verticalScrollbarContent.height(heightWithPadding) + @scrollBottom(height) if @scrollBottom() > height minWidth = @charWidth * @maxScreenLineLength() + 20 @@ -1516,7 +1520,8 @@ class Editor extends View # # Returns a {Number}. getLastVisibleScreenRow: -> - Math.max(0, Math.ceil((@scrollTop() + @scrollView.height()) / @lineHeight) - 1) + calculatedRow = Math.ceil((@scrollTop() + @scrollView.height()) / @lineHeight) - 1 + Math.max(0, Math.min(@getScreenLineCount() - 1, calculatedRow)) # Public: Given a row number, identifies if it is currently visible. #