mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
When DisplayBuffer.foldBufferRow is called with a buffer row that is within a fold, it folds the scope that incloses the buffer row's fold
This commit is contained in:
@@ -194,6 +194,15 @@ describe "DisplayBuffer", ->
|
||||
expect(fold.startRow).toBe 1
|
||||
expect(fold.endRow).toBe 9
|
||||
|
||||
describe "when the bufferRow is already folded", ->
|
||||
it "searches upward for the first row that begins a syntatic region containing the folded row (and folds it)", ->
|
||||
displayBuffer.foldBufferRow(2)
|
||||
expect(displayBuffer.lineForRow(1).fold).toBeDefined()
|
||||
expect(displayBuffer.lineForRow(0).fold).not.toBeDefined()
|
||||
|
||||
displayBuffer.foldBufferRow(1)
|
||||
expect(displayBuffer.lineForRow(0).fold).toBeDefined()
|
||||
|
||||
describe ".unfoldBufferRow(bufferRow)", ->
|
||||
describe "when bufferRow can be unfolded", ->
|
||||
it "destroys a fold based on the syntactic region starting at the given row", ->
|
||||
|
||||
@@ -61,18 +61,14 @@ class DisplayBuffer
|
||||
[startRow, endRow] = @tokenizedBuffer.rowRangeForFoldAtBufferRow(currentRow) ? []
|
||||
continue unless startRow? and startRow <= bufferRow <= endRow
|
||||
fold = @largestFoldStartingAtBufferRow(startRow)
|
||||
@createFold(startRow, endRow) unless fold
|
||||
continue if fold
|
||||
|
||||
@createFold(startRow, endRow)
|
||||
|
||||
return
|
||||
|
||||
unfoldBufferRow: (bufferRow) ->
|
||||
for currentRow in [bufferRow..0]
|
||||
[startRow, endRow] = @tokenizedBuffer.rowRangeForFoldAtBufferRow(currentRow) ? []
|
||||
continue unless startRow? and startRow <= bufferRow <= endRow
|
||||
fold = @largestFoldStartingAtBufferRow(startRow)
|
||||
fold.destroy() if fold
|
||||
|
||||
return
|
||||
@largestFoldContainingBufferRow(bufferRow)?.destroy()
|
||||
|
||||
createFold: (startRow, endRow) ->
|
||||
return fold if fold = @foldFor(startRow, endRow)
|
||||
|
||||
Reference in New Issue
Block a user