Folds include their first line

This commit is contained in:
Corey Johnson
2012-05-30 16:55:15 -07:00
parent 42e743f44a
commit 17b50ee8dc
5 changed files with 20 additions and 31 deletions

View File

@@ -2443,10 +2443,10 @@ describe "Editor", ->
editor.setCursorBufferPosition([1,0])
editor.trigger "toggle-fold"
expect(editor.screenLineForRow(2).fold).toBeDefined()
expect(editor.screenLineForRow(1).fold).toBeDefined()
editor.trigger "toggle-fold"
expect(editor.screenLineForRow(2).fold).toBeUndefined()
expect(editor.screenLineForRow(1).fold).toBeUndefined()
describe "primitive folding", ->
beforeEach ->

View File

@@ -19,8 +19,8 @@ describe "FoldSuggester", ->
describe ".rowRangeForFoldAtBufferRow(bufferRow)", ->
it "returns the start/end rows of the foldable region starting at the given row", ->
expect(foldSuggester.rowRangeForFoldAtBufferRow(0)).toEqual [1, 12]
expect(foldSuggester.rowRangeForFoldAtBufferRow(1)).toEqual [2, 9]
expect(foldSuggester.rowRangeForFoldAtBufferRow(0)).toEqual [0, 12]
expect(foldSuggester.rowRangeForFoldAtBufferRow(1)).toEqual [1, 9]
expect(foldSuggester.rowRangeForFoldAtBufferRow(2)).toBeNull()
expect(foldSuggester.rowRangeForFoldAtBufferRow(4)).toEqual [5, 7]
expect(foldSuggester.rowRangeForFoldAtBufferRow(4)).toEqual [4, 7]

View File

@@ -161,26 +161,20 @@ describe "Renderer", ->
describe "when bufferRow can be folded", ->
it "creates/destroys a fold based on the syntactic region starting at the given row", ->
renderer.toggleFoldAtBufferRow(1)
fold = renderer.lineForRow(2).fold
expect(fold.startRow).toBe 2
fold = renderer.lineForRow(1).fold
expect(fold.startRow).toBe 1
expect(fold.endRow).toBe 9
renderer.toggleFoldAtBufferRow(1)
expect(renderer.lineForRow(2).fold).toBeUndefined()
expect(renderer.lineForRow(1).fold).toBeUndefined()
describe "when bufferRow can't be folded", ->
it "searches upward for the first row that begins a syntatic region containing the given buffer row (and folds it)", ->
renderer.toggleFoldAtBufferRow(8)
fold = renderer.lineForRow(2).fold
expect(fold.startRow).toBe 2
fold = renderer.lineForRow(1).fold
expect(fold.startRow).toBe 1
expect(fold.endRow).toBe 9
describe "when the cursor is on a folded line", ->
it "destroys the fold", ->
renderer.toggleFoldAtBufferRow(1)
renderer.toggleFoldAtBufferRow(2)
expect(renderer.lineForRow(2).fold).toBeUndefined()
describe "primitive folding", ->
beforeEach ->
buffer = new Buffer(require.resolve 'fixtures/two-hundred.txt')