Folds can start at the same position as their nested folds

This commit is contained in:
Nathan Sobo
2012-02-29 11:47:55 -07:00
parent 20dff5e79d
commit 7f13f9b946
2 changed files with 13 additions and 2 deletions

View File

@@ -101,6 +101,11 @@ describe "LineFolder", ->
fold2.destroy()
expect(folder.lineForScreenRow(5).text).toBe " return sort(left).concat(pivot).concat(sort(right));"
it "allows the outer fold to start at the same location as the inner fold", ->
fold1 = folder.createFold(new Range([4, 29], [7, 4]))
fold2 = folder.createFold(new Range([4, 29], [9, 2]))
expect(folder.lineForScreenRow(4).text).toBe " while(items.length > 0) {...};"
describe "when another fold begins on the last line of a fold", ->
describe "when the second fold is created before the first fold", ->
it "renders a placeholder for both folds on the first line of the first fold", ->
@@ -180,7 +185,7 @@ describe "LineFolder", ->
expect(event.newRange).toEqual [[7, 0], [8, 56]]
describe "when creating a fold on the first line of an existing fold", ->
fit "renders the line correctly", ->
it "renders the line correctly", ->
folder.createFold(new Range([4, 29], [7, 4]))
folder.createFold(new Range([4, 10], [4, 26]))
expect(folder.lineForScreenRow(4).text).toBe ' while(...) {...}'

View File

@@ -196,4 +196,10 @@ class Fold
newRange.end.add(point.subtract(oldRange.end))
compare: (other) ->
@start.compare(other.start)
startComparison = @start.compare(other.start)
if startComparison == 0
other.end.compare(@end)
else
startComparison