mirror of
https://github.com/atom/atom.git
synced 2026-01-25 14:59:03 -05:00
Restore invalidated anchor points on undo/redo of a change
This commit is contained in:
@@ -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] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user