From 6e34124f1293292330850e7353f66f55e50268f0 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 29 May 2012 13:07:24 -0600 Subject: [PATCH] Overdraw gutter line numbers in addition to editor lines --- spec/app/editor-spec.coffee | 10 +++++----- src/app/editor.coffee | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index ae672215d..d2ad037ae 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -718,11 +718,11 @@ fdescribe "Editor", -> describe "when the editor is scrolled vertically", -> it "adjusts the padding-top to account for non-rendered line numbers", -> editor.scrollTop(editor.lineHeight * 3.5) - expect(editor.gutter.lineNumbers.css('padding-top')).toBe "#{editor.lineHeight * 3}px" - expect(editor.gutter.lineNumbers.css('padding-bottom')).toBe "#{editor.lineHeight * 4}px" - expect(editor.visibleLines.find('.line').length).toBe 6 - expect(editor.gutter.find('.line-number:first').text()).toBe "4" - expect(editor.gutter.find('.line-number:last').text()).toBe "9" + expect(editor.gutter.lineNumbers.css('padding-top')).toBe "#{editor.lineHeight * 1}px" + expect(editor.gutter.lineNumbers.css('padding-bottom')).toBe "#{editor.lineHeight * 2}px" + expect(editor.visibleLines.find('.line').length).toBe 10 + expect(editor.gutter.find('.line-number:first').text()).toBe "2" + expect(editor.gutter.find('.line-number:last').text()).toBe "11" describe "font size", -> it "sets the initial font size based on the value assigned to the root view", -> diff --git a/src/app/editor.coffee b/src/app/editor.coffee index b2bc720ae..95d5b9aba 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -303,12 +303,11 @@ class Editor extends View updateVisibleLines: -> firstVisibleScreenRow = @getFirstVisibleScreenRow() lastVisibleScreenRow = @getLastVisibleScreenRow() - - @gutter.renderLineNumbers(firstVisibleScreenRow, lastVisibleScreenRow) - renderFrom = Math.max(0, firstVisibleScreenRow - @lineOverdraw) renderTo = Math.min(@getLastScreenRow(), lastVisibleScreenRow + @lineOverdraw) + @gutter.renderLineNumbers(renderFrom, renderTo) + if firstVisibleScreenRow < @firstRenderedScreenRow @removeLineElements(Math.max(@firstRenderedScreenRow, renderTo + 1), @lastRenderedScreenRow) @lastRenderedScreenRow = renderTo