Don’t attempt to preserve mouseWheelScreenRow if it’s deleted

Fixes #5527
This commit is contained in:
Nathan Sobo
2015-02-23 10:47:21 -08:00
parent e55e84506b
commit 2e8c5855d4
2 changed files with 7 additions and 2 deletions

View File

@@ -839,6 +839,11 @@ describe "TextEditorPresenter", ->
expect(presenter.state.content.lines[oldLine3.id]).toBeUndefined()
expect(presenter.state.content.lines[newLine3.id]).toBeDefined()
it "does not attempt to preserve lines corresponding to ::mouseWheelScreenRow if they have been deleted", ->
presenter = buildPresenter(explicitHeight: 25, scrollTop: 0, lineHeight: 10, lineOverdrawMargin: 1, stoppedScrollingDelay: 200)
presenter.setMouseWheelScreenRow(10)
editor.setText('')
describe "[lineId]", -> # line state objects
it "includes the .endOfLineInvisibles if the editor.showInvisibles config option is true", ->
editor.setText("hello\nworld\r\n")

View File

@@ -228,8 +228,8 @@ class TextEditorPresenter
row++
if @mouseWheelScreenRow?
preservedLine = @model.tokenizedLineForScreenRow(@mouseWheelScreenRow)
visibleLineIds[preservedLine.id] = true
if preservedLine = @model.tokenizedLineForScreenRow(@mouseWheelScreenRow)
visibleLineIds[preservedLine.id] = true
for id, line of @state.content.lines
unless visibleLineIds.hasOwnProperty(id)