diff --git a/spec/app/buffer-spec.coffee b/spec/app/buffer-spec.coffee index 84fea60db..f6ae76471 100644 --- a/spec/app/buffer-spec.coffee +++ b/spec/app/buffer-spec.coffee @@ -665,7 +665,7 @@ describe 'Buffer', -> anchor2Id = buffer.addAnchorPoint([4, 23], ignoreSameLocationInserts: true) anchor3Id = buffer.addAnchorPoint([4, 23], surviveSurroundingChanges: true) - describe "when the buffer changes", -> + describe "when the buffer changes due to a new operation", -> describe "when the change precedes the anchor point", -> it "moves the anchor", -> buffer.insert([4, 5], '...') @@ -716,6 +716,21 @@ describe 'Buffer', -> buffer.undo() expect(buffer.getAnchorPoint(anchor1Id)).toEqual [4, 23] + describe "when the buffer changes due to the undo or redo of a previous operation", -> + it "restores invalidated anchor points when undoing/redoing in the other direction", -> + buffer.change([[4, 21], [4, 24]], "foo") + expect(buffer.getAnchorPoint(anchor1Id)).toBeUndefined() + anchor4Id = buffer.addAnchorPoint([4, 23]) + buffer.undo() + expect(buffer.getAnchorPoint(anchor1Id)).toEqual [4, 23] + expect(buffer.getAnchorPoint(anchor4Id)).toBeUndefined() + anchor5Id = buffer.addAnchorPoint([4, 23]) + buffer.redo() + expect(buffer.getAnchorPoint(anchor4Id)).toEqual [4, 23] + expect(buffer.getAnchorPoint(anchor5Id)).toBeUndefined() + buffer.undo() + expect(buffer.getAnchorPoint(anchor5Id)).toEqual [4, 23] + describe "anchors", -> [anchor, destroyHandler] = []