     row = Math.min(@editor.getLastVisibleScreenRow(), vimLastScreenRow)
     offset = @getScrolloff() + 1
     offset = 0 if row is vimLastScreenRow
-    offset = Math.max(@getCount(), offset)
+    offset = Math.max(@getCount(-1), offset)
     row - offset
 
 # Scrolling

    row = getFirstVisibleScreenRow(@editor)
    offset = @getScrolloff()
    offset = 0 if (row is 0)
    offset = Math.max(@getCount(), offset)
    row + offset

# keymap: M

  scrolloff: 2
  defaultCount: 0

  moveCursor: (cursor) ->
    cursor.setBufferPosition(@getPoint())

