🐛 Guard against unexisting screen rows

This commit is contained in:
Antonio Scandurra 2016-03-24 15:57:24 +01:00
parent 87489d4b0b
commit e6cb5c8e89
2 changed files with 3 additions and 1 deletions

View File

@ -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", ->

View File

@ -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