From 2e8c5855d406cf939191964a803580cf39b75fd0 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 23 Feb 2015 10:47:21 -0800 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20attempt=20to=20preserve=20mouse?= =?UTF-8?q?WheelScreenRow=20if=20it=E2=80=99s=20deleted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #5527 --- spec/text-editor-presenter-spec.coffee | 5 +++++ src/text-editor-presenter.coffee | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) 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)