Remove toggleFold and replace with fold

This commit is contained in:
Corey Johnson
2012-07-27 13:46:50 -07:00
parent 76ffa5a2c5
commit 7ff31d1ad7
4 changed files with 32 additions and 52 deletions

View File

@@ -65,15 +65,14 @@ class DisplayBuffer
return
unfoldScopeContainingBufferRow: (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
isFoldContainedByActiveFold: (fold) ->
for row, folds of @activeFolds
for otherFold in folds
return otherFold if fold != otherFold and fold.isContainedByFold(otherFold)
foldFor: (startRow, endRow) ->
_.find @activeFolds[startRow] ? [], (fold) ->
fold.startRow == startRow and fold.endRow == endRow
return
createFold: (startRow, endRow) ->
return fold if fold = @foldFor(startRow, endRow)
@@ -92,6 +91,15 @@ class DisplayBuffer
fold
isFoldContainedByActiveFold: (fold) ->
for row, folds of @activeFolds
for otherFold in folds
return otherFold if fold != otherFold and fold.isContainedByFold(otherFold)
foldFor: (startRow, endRow) ->
_.find @activeFolds[startRow] ? [], (fold) ->
fold.startRow == startRow and fold.endRow == endRow
destroyFold: (fold) ->
@unregisterFold(fold.startRow, fold)

View File

@@ -200,7 +200,10 @@ class EditSession
fold: ->
bufferRow = @bufferPositionForScreenPosition(@getCursorScreenPosition()).row
@foldAtBufferRow(bufferRow)
@foldScopeContainingBufferRow(bufferRow)
foldScopeContainingBufferRow: (bufferRow) ->
@displayBuffer.foldScopeContainingBufferRow(bufferRow)
foldSelection: ->
selection.fold() for selection in @getSelections()