From e6cb5c8e89aab9ac347891d95fadc4137f1f9d69 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 24 Mar 2016 15:57:24 +0100 Subject: [PATCH] :bug: Guard against unexisting screen rows --- spec/text-editor-spec.coffee | 3 ++- src/text-editor.coffee | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) 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