mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Make Editor::unfoldBufferRow destroy all folds containing the buffer row
Also, remove ::destroyAllFoldsContainingBufferRow as it is now redundant
This commit is contained in:
@@ -169,7 +169,7 @@ class DisplayBuffer extends Model
|
||||
# Removes any folds found that contain the given buffer row.
|
||||
#
|
||||
# bufferRow - The buffer row {Number} to check against
|
||||
destroyFoldsContainingBufferRow: (bufferRow) ->
|
||||
unfoldBufferRow: (bufferRow) ->
|
||||
fold.destroy() for fold in @foldsContainingBufferRow(bufferRow)
|
||||
|
||||
# Given a buffer row, this returns the largest fold that starts there.
|
||||
|
||||
@@ -788,14 +788,11 @@ class Editor extends Model
|
||||
foldBufferRow: (bufferRow) ->
|
||||
@languageMode.foldBufferRow(bufferRow)
|
||||
|
||||
# Destroy the largest fold containing the given row in buffer
|
||||
# coordinates.
|
||||
# Public: Unfold all folds containing the given row in buffer coordinates.
|
||||
#
|
||||
# bufferRow - A {Number}
|
||||
#
|
||||
# TODO: Should this destroy all folds containing the given buffer row?
|
||||
unfoldBufferRow: (bufferRow) ->
|
||||
@languageMode.unfoldBufferRow(bufferRow)
|
||||
@displayBuffer.unfoldBufferRow(bufferRow)
|
||||
|
||||
# Public: Determine whether the given row in buffer coordinates is foldable.
|
||||
#
|
||||
@@ -815,14 +812,10 @@ class Editor extends Model
|
||||
destroyFoldWithId: (id) ->
|
||||
@displayBuffer.destroyFoldWithId(id)
|
||||
|
||||
# {Delegates to: DisplayBuffer.destroyFoldsContainingBufferRow}
|
||||
destroyFoldsContainingBufferRow: (bufferRow) ->
|
||||
@displayBuffer.destroyFoldsContainingBufferRow(bufferRow)
|
||||
|
||||
# Remove any {Fold}s found that intersect the given buffer row.
|
||||
destroyFoldsIntersectingBufferRange: (bufferRange) ->
|
||||
for row in [bufferRange.start.row..bufferRange.end.row]
|
||||
@destroyFoldsContainingBufferRow(row)
|
||||
@unfoldBufferRow(row)
|
||||
|
||||
# Public: Fold the given buffer row if it isn't currently folded, and unfold
|
||||
# it otherwise.
|
||||
@@ -904,7 +897,7 @@ class Editor extends Model
|
||||
|
||||
# Make sure the inserted text doesn't go into an existing fold
|
||||
if fold = @displayBuffer.largestFoldStartingAtBufferRow(insertPosition.row)
|
||||
@destroyFoldsContainingBufferRow(insertPosition.row)
|
||||
@unfoldBufferRow(insertPosition.row)
|
||||
foldedRows.push(insertPosition.row + endRow - startRow + fold.getBufferRange().getRowCount())
|
||||
|
||||
@buffer.insert(insertPosition, lines)
|
||||
@@ -960,7 +953,7 @@ class Editor extends Model
|
||||
|
||||
# Make sure the inserted text doesn't go into an existing fold
|
||||
if fold = @displayBuffer.largestFoldStartingAtBufferRow(insertPosition.row)
|
||||
@destroyFoldsContainingBufferRow(insertPosition.row)
|
||||
@unfoldBufferRow(insertPosition.row)
|
||||
foldedRows.push(insertPosition.row + fold.getBufferRange().getRowCount())
|
||||
|
||||
@buffer.insert(insertPosition, lines)
|
||||
|
||||
@@ -121,12 +121,6 @@ class LanguageMode
|
||||
fold = @editor.displayBuffer.largestFoldStartingAtBufferRow(startRow)
|
||||
return @editor.createFold(startRow, endRow) unless fold
|
||||
|
||||
# Given a buffer row, this unfolds it.
|
||||
#
|
||||
# bufferRow - A {Number} indicating the buffer row
|
||||
unfoldBufferRow: (bufferRow) ->
|
||||
@editor.displayBuffer.largestFoldContainingBufferRow(bufferRow)?.destroy()
|
||||
|
||||
# Find the row range for a fold at a given bufferRow. Will handle comments
|
||||
# and code.
|
||||
#
|
||||
|
||||
@@ -282,7 +282,7 @@ class Selection
|
||||
# :undo - if `skip`, skips the undo stack for this operation.
|
||||
insertText: (text, options={}) ->
|
||||
oldBufferRange = @getBufferRange()
|
||||
@editor.destroyFoldsContainingBufferRow(oldBufferRange.end.row)
|
||||
@editor.unfoldBufferRow(oldBufferRange.end.row)
|
||||
wasReversed = @isReversed()
|
||||
@clear()
|
||||
@cursor.needsAutoscroll = @cursor.isLastCursor()
|
||||
@@ -334,11 +334,15 @@ class Selection
|
||||
|
||||
normalizedLines.join('\n')
|
||||
|
||||
# Public: Indents the selection.
|
||||
# Indent the current line(s).
|
||||
#
|
||||
# If the selection is empty, indents the current line if the cursor precedes
|
||||
# non-whitespace characters, and otherwise inserts a tab. If the selection is
|
||||
# non empty, calls {::indentSelectedRows}.
|
||||
#
|
||||
# options - A {Object} with the keys:
|
||||
# :autoIndent - If `true`, the indentation is performed appropriately.
|
||||
# Otherwise, {Editor::getTabText} is used.
|
||||
# :autoIndent - If `true`, the line is indented to an automatically-inferred
|
||||
# level. Otherwise, {Editor::getTabText} is inserted.
|
||||
indent: ({ autoIndent }={})->
|
||||
{ row, column } = @cursor.getBufferPosition()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user