diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 9c9cf1475..f16298029 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -4561,7 +4561,8 @@ describe "TextEditor", -> it '.lineTextForScreenRow(row)', -> editor.foldBufferRow(4) expect(editor.lineTextForScreenRow(5)).toEqual ' return sort(left).concat(pivot).concat(sort(right));' - expect(editor.lineTextForScreenRow(100)).not.toBeDefined() + expect(editor.lineTextForScreenRow(9)).toEqual '};' + expect(editor.lineTextForScreenRow(10)).toBeUndefined() describe ".deleteLine()", -> it "deletes the first line when the cursor is there", -> diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 2200ce827..7b77e4403 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -783,6 +783,7 @@ class TextEditor extends Model @displayLayer.tagForCode(tagCode) screenLineForScreenRow: (screenRow) -> + return if screenRow < 0 or screenRow > @getLastScreenRow() @displayLayer.getScreenLines(screenRow, screenRow + 1)[0] bufferRowForScreenRow: (row) -> @displayLayer.translateScreenPosition(Point(row, 0)).row