Nested folds can start at the same row as the fold that contains them

...still need to test destroying the outer fold though.
This commit is contained in:
Nathan Sobo 2012-05-18 20:14:05 -06:00
parent 9757786257
commit c491d92437
2 changed files with 14 additions and 7 deletions

View File

@ -316,10 +316,16 @@ describe "Renderer", ->
expect(line6.screenDelta).toEqual [1, 0]
expect(line7.text).toBe '8'
it "allows the outer fold to start at the same location as the inner fold", ->
renderer.createFold([[4, 29], [7, 4]])
renderer.createFold([[4, 29], [9, 2]])
expect(renderer.lineForRow(4).text).toBe " while(items.length > 0) {...};"
fit "allows the outer fold to start at the same location as the inner fold", ->
innerFold = renderer.createFold(4, 6)
outerFold = renderer.createFold(4, 8)
[line4, line5] = renderer.linesForRows(4, 5)
expect(line4.fold).toBe outerFold
expect(line4.text).toMatch /4-+/
expect(line4.bufferDelta).toEqual [5, 0]
expect(line4.screenDelta).toEqual [1, 0]
expect(line5.text).toMatch /9-+/
describe "when a fold begins on the line on which another fold ends", ->
describe "when the second fold is created before the first fold", ->

View File

@ -137,7 +137,7 @@ class Renderer
while startBufferRow <= endBufferRow
screenLine = @highlighter.lineForRow(startBufferRow)
if fold = @foldForBufferRow(startBufferRow)
if fold = @largestFoldForBufferRow(startBufferRow)
screenLine = screenLine.copy()
screenLine.fold = fold
screenLine.bufferDelta = fold.getBufferDelta()
@ -184,8 +184,9 @@ class Renderer
_.remove(folds, fold)
delete @foldsById[fold.id]
foldForBufferRow: (bufferRow) ->
@activeFolds[bufferRow]?[0]
largestFoldForBufferRow: (bufferRow) ->
return unless folds = @activeFolds[bufferRow]
(folds.sort (a, b) -> b.endRow - a.endRow)[0]
buildFoldPlaceholder: (fold) ->