Fix folding with splits

Fixes #4099

Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
Max Brunsfeld
2015-01-13 17:36:08 -08:00
parent 76b7a8cec9
commit 0d5a707ffb
2 changed files with 9 additions and 5 deletions

View File

@@ -351,11 +351,16 @@ describe "DisplayBuffer", ->
expect(displayBuffer.tokenizedLineForScreenRow(1).text).toMatch /^10/
describe "when there is another display buffer pointing to the same buffer", ->
it "does not create folds in the other display buffer", ->
it "does not consider folds to be nested inside of folds from the other display buffer", ->
otherDisplayBuffer = new DisplayBuffer({buffer, tabLength})
otherDisplayBuffer.createFold(1, 5)
displayBuffer.createFold(2, 4)
expect(otherDisplayBuffer.foldsStartingAtBufferRow(2).length).toBe 0
expect(displayBuffer.tokenizedLineForScreenRow(2).text).toBe '2'
expect(displayBuffer.tokenizedLineForScreenRow(3).text).toBe '5'
describe "when the buffer changes", ->
[fold1, fold2] = []
beforeEach ->

View File

@@ -19,10 +19,9 @@ class Fold
# Returns whether this fold is contained within another fold
isInsideLargerFold: ->
if largestContainingFoldMarker = @displayBuffer.findMarker(class: 'fold', containsBufferRange: @getBufferRange())
not largestContainingFoldMarker.getBufferRange().isEqual(@getBufferRange())
else
false
largestContainingFoldMarker = @displayBuffer.findFoldMarker(containsRange: @getBufferRange())
largestContainingFoldMarker and
not largestContainingFoldMarker.getRange().isEqual(@getBufferRange())
# Destroys this fold
destroy: ->