Add unfold-all and bind it to ctrl-}

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-07-30 12:11:54 -07:00
parent a7db67e68d
commit f7614c210a
5 changed files with 23 additions and 4 deletions

View File

@@ -56,6 +56,10 @@ class DisplayBuffer
@createFold(startRow, endRow)
unfoldAll: ->
for row in [@buffer.getLastRow()..0]
@activeFolds[row]?.forEach (fold) => @destroyFold(fold)
foldBufferRow: (bufferRow) ->
for currentRow in [bufferRow..0]
[startRow, endRow] = @tokenizedBuffer.rowRangeForFoldAtBufferRow(currentRow) ? []
@@ -123,6 +127,7 @@ class DisplayBuffer
folds = @activeFolds[bufferRow]
_.remove(folds, fold)
delete @foldsById[fold.id]
delete @activeFolds[bufferRow] if folds.length == 0
largestFoldStartingAtBufferRow: (bufferRow) ->
return unless folds = @activeFolds[bufferRow]

View File

@@ -198,6 +198,12 @@ class EditSession
redo: ->
@buffer.redo(this)
foldAll: ->
@displayBuffer.foldAll()
unfoldAll: ->
@displayBuffer.unfoldAll()
foldCurrentRow: ->
bufferRow = @bufferPositionForScreenPosition(@getCursorScreenPosition()).row
@foldBufferRow(bufferRow)
@@ -215,9 +221,6 @@ class EditSession
foldSelection: ->
selection.fold() for selection in @getSelections()
foldAll: ->
@displayBuffer.foldAll()
createFold: (startRow, endRow) ->
@displayBuffer.createFold(startRow, endRow)

View File

@@ -139,6 +139,7 @@ class Editor extends View
'newline-below': @insertNewlineBelow
'toggle-soft-wrap': @toggleSoftWrap
'fold-all': @foldAll
'unfold-all': @unfoldAll
'fold-current-row': @foldCurrentRow
'unfold-current-row': @unfoldCurrentRow
'fold-selection': @foldSelection
@@ -223,6 +224,7 @@ class Editor extends View
foldCurrentRow: -> @activeEditSession.foldCurrentRow()
unfoldCurrentRow: -> @activeEditSession.unfoldCurrentRow()
foldAll: -> @activeEditSession.foldAll()
unfoldAll: -> @activeEditSession.unfoldAll()
foldSelection: -> @activeEditSession.foldSelection()
destroyFold: (foldId) -> @activeEditSession.destroyFold(foldId)
destroyFoldsContainingBufferRow: (bufferRow) -> @activeEditSession.destroyFoldsContainingBufferRow(bufferRow)

View File

@@ -19,7 +19,8 @@ window.keymap.bindKeys '.editor',
'alt-meta-w': 'toggle-soft-wrap'
'ctrl-[': 'fold-current-row'
'ctrl-]': 'unfold-current-row'
'ctrl-(': 'fold-all'
'ctrl-{': 'fold-all'
'ctrl-}': 'unfold-all'
'alt-meta-ctrl-f': 'fold-selection'
'alt-meta-left': 'split-left'
'alt-meta-right': 'split-right'