diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index f5c7612c4..bfee6598b 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -765,6 +765,18 @@ describe "Editor", -> expect(editor.getSelectionViews().length).toBe 1 expect(editor.find('.region').length).toBe 3 + describe "when a selection is added and removed before the display is updated", -> + it "does not attempt to render the selection", -> + # don't update display until we request it + jasmine.unspy(editor, 'requestDisplayUpdate') + spyOn(editor, 'requestDisplayUpdate') + + editSession = editor.activeEditSession + selection = editSession.addSelectionForBufferRange([[3, 0], [3, 4]]) + selection.destroy() + editor.updateDisplay() + expect(editor.getSelectionViews().length).toBe 1 + describe "when the selection is created with the selectAll event", -> it "does not scroll to the end of the buffer", -> editor.height(150) diff --git a/src/app/cursor.coffee b/src/app/cursor.coffee index 4832b74d8..a30f77f93 100644 --- a/src/app/cursor.coffee +++ b/src/app/cursor.coffee @@ -34,6 +34,7 @@ class Cursor @needsAutoscroll = true destroy: -> + @destroyed = true @editSession.destroyMarker(@marker) @editSession.removeCursor(this) @trigger 'destroyed' diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 026a00e49..335523c49 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -780,7 +780,7 @@ class Editor extends View updateCursorViews: -> if @newCursors.length > 0 - @addCursorView(cursor) for cursor in @newCursors + @addCursorView(cursor) for cursor in @newCursors when not cursor.destroyed @syncCursorAnimations() @newCursors = [] @@ -792,7 +792,7 @@ class Editor extends View updateSelectionViews: -> if @newSelections.length > 0 - @addSelectionView(selection) for selection in @newSelections + @addSelectionView(selection) for selection in @newSelections when not selection.destroyed @newSelections = [] for selectionView in @getSelectionViews()