     beforeEach ->
       editor.attachToDom(heightInLines: 5.5)
 
-    it "creates a line number element for visible lines", ->
-      expect(editor.gutter.find('.line-number').length).toEqual(6)
+    it "creates a line number element for each visible line, plus overdraw", ->
+      expect(editor.gutter.find('.line-number').length).toEqual(8)
       expect(editor.gutter.find('.line-number:first').text()).toBe "1"
-      expect(editor.gutter.find('.line-number:last').text()).toBe "6"
+      expect(editor.gutter.find('.line-number:last').text()).toBe "8"
 
       editor.verticalScrollbar.scrollTop(editor.lineHeight * 1.5)
       editor.verticalScrollbar.trigger 'scroll'
-      expect(editor.visibleLines.find('.line').length).toBe 6
+      expect(editor.visibleLines.find('.line').length).toBe 8
+      expect(editor.gutter.find('.line-number:first').text()).toBe "1"
+      expect(editor.gutter.find('.line-number:last').text()).toBe "9"
+
+      editor.verticalScrollbar.scrollTop(editor.lineHeight * 3.5)
+      editor.verticalScrollbar.trigger 'scroll'
+      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 "7"
+      expect(editor.gutter.find('.line-number:last').text()).toBe "11"
 
     describe "width", ->
       it "sets the width based on last line number", ->

_ = require 'underscore'
fs = require 'fs'

fdescribe "Editor", ->
  [rootView, buffer, editor, cachedLineHeight] = []

  getLineHeight = ->

    describe "when a selected fold is scrolled into view (and the fold line was not previously rendered)", ->
      it "renders the fold's line element with the 'selected' class", ->
        setEditorHeightInLines(editor, 5)
        editor.renderVisibleLines() # re-render lines so certain lines are not rendered

        editor.createFold(2, 4)
        editor.setSelectionBufferRange([[1, 0], [5, 0]])
