From 523a255e48ee9ee93efb663acc15a3544838a684 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Wed, 3 Sep 2014 14:08:43 -0700 Subject: [PATCH] Add Editor::lineTextForScreenRow() Closes #3055 --- spec/editor-spec.coffee | 5 +++++ src/editor.coffee | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index 2852af9e1..18f0b33b4 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -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() diff --git a/src/editor.coffee b/src/editor.coffee index 8ce5c6de4..1e809dc52 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -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.