diff --git a/spec/atom/editor-spec.coffee b/spec/atom/editor-spec.coffee index 1c3b235d3..ca3fd36c7 100644 --- a/spec/atom/editor-spec.coffee +++ b/spec/atom/editor-spec.coffee @@ -98,6 +98,13 @@ describe "Editor", -> $(window).trigger 'resize' expect(editor.setMaxLineLength).not.toHaveBeenCalled() + it "allows the cursor to move down to the last line", -> + _.times editor.lastScreenRow(), -> editor.moveCursorDown() + expect(editor.getCursorScreenPosition()).toEqual [editor.lastScreenRow(), 0] + editor.moveCursorDown() + expect(editor.getCursorScreenPosition()).toEqual [editor.lastScreenRow(), 2] + + describe "cursor movement", -> describe ".setCursorScreenPosition({row, column})", -> beforeEach -> diff --git a/src/atom/cursor.coffee b/src/atom/cursor.coffee index 87dfab2cf..f52460f41 100644 --- a/src/atom/cursor.coffee +++ b/src/atom/cursor.coffee @@ -60,11 +60,7 @@ class Cursor extends View moveDown: -> { row, column } = @getScreenPosition() column = @goalColumn if @goalColumn? - if row < @editor.buffer.numLines() - 1 - @setScreenPosition({row: row + 1, column: column}) - else - @moveToLineEnd() - + @setScreenPosition({row: row + 1, column: column}) @goalColumn = column moveToLineEnd: -> diff --git a/src/atom/editor.coffee b/src/atom/editor.coffee index d690a4565..b822d41af 100644 --- a/src/atom/editor.coffee +++ b/src/atom/editor.coffee @@ -141,6 +141,12 @@ class Editor extends View linesForScreenRows: (start, end) -> @lineWrapper.linesForScreenRows(start, end) + screenLineCount: -> + @lineWrapper.lineCount() + + lastScreenRow: -> + @screenLineCount() - 1 + setBuffer: (@buffer) -> @highlighter = new Highlighter(@buffer) @lineFolder = new LineFolder(@highlighter)