When updating folds, don't modify the array over which we're iterating

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-03-16 16:31:52 -06:00
parent 67d017f3f4
commit b31bef4ea0
2 changed files with 13 additions and 1 deletions

View File

@@ -464,6 +464,18 @@ describe "Renderer", ->
expect(event.oldRange).toEqual [[4, 0], [4, 56]]
expect(event.newRange).toEqual [[4, 0], [4, 60]]
describe "when the old range surrounds two nested folds", ->
it "removes both folds and replaces the fold placeholder with the new text", ->
renderer.createFold([[4, 25], [7, 5]])
buffer.change([[4, 25], [7, 5]], '4)')
expect(renderer.lineForRow(4).text).toBe ' while(items.length > 4)...concat(sort(right));'
# expect(changeHandler).toHaveBeenCalled()
# [[event]] = changeHandler.argsForCall
# expect(event.oldRange).toEqual [[4, 0], [4, 56]]
# expect(event.newRange).toEqual [[4, 0], [4, 60]]
describe "position translation", ->
describe "when there is single fold spanning multiple lines", ->
it "translates positions to account for folded lines and characters and the placeholder", ->

View File

@@ -117,7 +117,7 @@ class Renderer
handleBufferChange: (e) ->
for row, folds of @activeFolds
for fold in folds
for fold in new Array(folds...)
changeInsideFold = true if fold.handleBufferChange(e)
unless changeInsideFold