mirror of
https://github.com/atom/atom.git
synced 2026-02-09 22:24:59 -05:00
Add unfold-all and bind it to ctrl-}
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user