diff --git a/spec/text-editor-presenter-spec.coffee b/spec/text-editor-presenter-spec.coffee index 7691b663f..163521c32 100644 --- a/spec/text-editor-presenter-spec.coffee +++ b/spec/text-editor-presenter-spec.coffee @@ -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") diff --git a/src/text-editor-presenter.coffee b/src/text-editor-presenter.coffee index 215398c05..b76666209 100644 --- a/src/text-editor-presenter.coffee +++ b/src/text-editor-presenter.coffee @@ -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)