mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 07:58:04 +03:00
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:
parent
9757786257
commit
c491d92437
@ -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", ->
|
||||
|
@ -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) ->
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user