Add Editor::lineTextForScreenRow()

Closes #3055
This commit is contained in:
Ben Ogle
2014-09-03 14:08:43 -07:00
parent 5e21d1ca5b
commit 523a255e48
2 changed files with 11 additions and 0 deletions

View File

@@ -2773,6 +2773,11 @@ describe "Editor", ->
expect(cursor1.getBufferPosition()).toEqual [0,0]
expect(cursor3.getBufferPosition()).toEqual [1,2]
describe 'reading text', ->
it '.lineTextForScreenRow(row)', ->
editor.foldBufferRow(4)
expect(editor.lineTextForScreenRow(5)).toEqual ' return sort(left).concat(pivot).concat(sort(right));'
describe ".deleteLine()", ->
it "deletes the first line when the cursor is there", ->
editor.getLastCursor().moveToTop()

View File

@@ -418,6 +418,12 @@ class Editor extends Model
deprecate 'Use Editor::lineTextForBufferRow(bufferRow) instead'
@lineTextForBufferRow(bufferRow)
# Public: Returns a {String} representing the contents of the line at the
# given screen row.
#
# * `screenRow` A {Number} representing a zero-indexed screen row.
lineTextForScreenRow: (screenRow) -> @displayBuffer.tokenizedLineForScreenRow(screenRow).text
# Gets the screen line for the given screen row.
#
# * `screenRow` - A {Number} indicating the screen row.