diff --git a/spec/atom/buffer-spec.coffee b/spec/atom/buffer-spec.coffee index 7f7033c16..c8d07e0de 100644 --- a/spec/atom/buffer-spec.coffee +++ b/spec/atom/buffer-spec.coffee @@ -141,7 +141,7 @@ describe 'Buffer', -> describe ".setText(text)", -> it "changes the entire contents of the buffer and emits a change event", -> - lastRow = buffer.lastRow() + lastRow = buffer.getLastRow() expectedPreRange = [[0,0], [lastRow, buffer.lineForRow(lastRow).length]] changeHandler = jasmine.createSpy('changeHandler') buffer.on 'change', changeHandler diff --git a/spec/atom/editor-spec.coffee b/spec/atom/editor-spec.coffee index f63ae5925..b700fae06 100644 --- a/spec/atom/editor-spec.coffee +++ b/spec/atom/editor-spec.coffee @@ -1007,7 +1007,7 @@ describe "Editor", -> describe ".clipScreenPosition(point)", -> it "selects the nearest valid position to the given point", -> - expect(editor.clipScreenPosition(row: 1000, column: 0)).toEqual(row: buffer.lastRow(), column: buffer.lineForRow(buffer.lastRow()).length) + expect(editor.clipScreenPosition(row: 1000, column: 0)).toEqual(row: buffer.getLastRow(), column: buffer.lineForRow(buffer.getLastRow()).length) expect(editor.clipScreenPosition(row: -5, column: 0)).toEqual(row: 0, column: 0) expect(editor.clipScreenPosition(row: 1, column: 10000)).toEqual(row: 1, column: buffer.lineForRow(1).length) expect(editor.clipScreenPosition(row: 1, column: -5)).toEqual(row: 1, column: 0) diff --git a/src/atom/buffer.coffee b/src/atom/buffer.coffee index a0c5053b9..082b328d5 100644 --- a/src/atom/buffer.coffee +++ b/src/atom/buffer.coffee @@ -27,7 +27,7 @@ class Buffer @change(@getRange(), text) getRange: -> - new Range([0, 0], [@lastRow(), @lastLine().length]) + new Range([0, 0], [@getLastRow(), @lastLine().length]) getTextInRange: (range) -> range = Range.fromObject(range) @@ -54,11 +54,11 @@ class Buffer numLines: -> @getLines().length - lastRow: -> + getLastRow: -> @getLines().length - 1 lastLine: -> - @lineForRow(@lastRow()) + @lineForRow(@getLastRow()) characterIndexForPosition: (position) -> position = Point.fromObject(position) @@ -77,7 +77,7 @@ class Buffer deleteRow: (row) -> range = null - if row == @lastRow() + if row == @getLastRow() range = new Range([row - 1, @getLineLength(row - 1)], [row, @getLineLength(row)]) else range = new Range([row, 0], [row + 1, 0]) diff --git a/src/atom/editor.coffee b/src/atom/editor.coffee index eb60e7332..b61f21923 100644 --- a/src/atom/editor.coffee +++ b/src/atom/editor.coffee @@ -372,7 +372,7 @@ class Editor extends View setText: (text) -> @buffer.setText(text) getText: -> @buffer.getText() - getLastBufferRow: -> @buffer.lastRow() + getLastBufferRow: -> @buffer.getLastRow() getBufferLineLength: (row) -> @buffer.getLineLength(row) insertText: (text) -> diff --git a/src/atom/highlighter.coffee b/src/atom/highlighter.coffee index d56166d98..916345669 100644 --- a/src/atom/highlighter.coffee +++ b/src/atom/highlighter.coffee @@ -10,7 +10,7 @@ class Highlighter constructor: (@buffer) -> @id = @constructor.idCounter++ - @screenLines = @buildLinesForScreenRows('start', 0, @buffer.lastRow()) + @screenLines = @buildLinesForScreenRows('start', 0, @buffer.getLastRow()) @buffer.on "change.highlighter#{@id}", (e) => @handleBufferChange(e) handleBufferChange: (e) -> @@ -27,7 +27,7 @@ class Highlighter # if it differs, re-tokenize the next line with the new state and repeat for # each line until the line's new state matches the previous state. this covers # cases like inserting a /* needing to comment out lines below until we see a */ - for row in [newRange.end.row...@buffer.lastRow()] + for row in [newRange.end.row...@buffer.getLastRow()] break if @screenLines[row].state == previousState nextRow = row + 1 previousState = @screenLines[nextRow].state @@ -66,9 +66,6 @@ class Highlighter linesForScreenRows: (startRow, endRow) -> @screenLines[startRow..endRow] - lastRow: -> - @screenLines.length - 1 - destroy: -> @buffer.off ".highlighter#{@id}" diff --git a/src/atom/renderer.coffee b/src/atom/renderer.coffee index 1c85221f9..14e677062 100644 --- a/src/atom/renderer.coffee +++ b/src/atom/renderer.coffee @@ -30,7 +30,7 @@ class Renderer buildLineMap: -> @lineMap = new LineMap - @lineMap.insertAtBufferRow 0, @buildLinesForBufferRows(0, @buffer.lastRow()) + @lineMap.insertAtBufferRow 0, @buildLinesForBufferRows(0, @buffer.getLastRow()) setMaxLineLength: (@maxLineLength) -> oldRange = @rangeForAllLines() @@ -100,12 +100,6 @@ class Renderer lineCount: -> @lineMap.screenLineCount() - lastRow: -> - @lineCount() - 1 - - logLines: -> - @lineMap.logLines() - screenPositionForBufferPosition: (position) -> @lineMap.screenPositionForBufferPosition(position) @@ -222,4 +216,7 @@ class Renderer @highlighter.destroy() @buffer.off ".renderer#{@id}" + logLines: -> + @lineMap.logLines() + _.extend Renderer.prototype, EventEmitter diff --git a/src/atom/vim-mode/motions.coffee b/src/atom/vim-mode/motions.coffee index 5b170a664..8df3f0fcd 100644 --- a/src/atom/vim-mode/motions.coffee +++ b/src/atom/vim-mode/motions.coffee @@ -75,13 +75,13 @@ class MoveToNextParagraph extends Motion column = 0 startRow = @editor.getCursorBufferRow() + 1 - for r in [startRow..@editor.buffer.lastRow()] + for r in [startRow..@editor.buffer.getLastRow()] if @editor.buffer.lineForRow(r).length == 0 row = r break if not row - row = @editor.buffer.lastRow() + row = @editor.buffer.getLastRow() column = @editor.buffer.lastLine().length - 1 new Point(row, column)