Destroy only containing folds on selection

This commit is contained in:
Antonio Scandurra
2015-03-11 16:16:45 +01:00
parent b05a36d9f0
commit 2b98192276
3 changed files with 14 additions and 9 deletions

View File

@@ -2241,7 +2241,7 @@ class TextEditor extends Model
# Returns the new {Selection}.
addSelection: (marker, options={}) ->
unless marker.getProperties().preserveFolds
@destroyFoldsIntersectingBufferRange(marker.getBufferRange())
@destroyFoldsContainingBufferRange(marker.getBufferRange())
cursor = @addCursor(marker)
selection = new Selection(_.extend({editor: this, marker, cursor}, options))
@selections.push(selection)
@@ -2776,12 +2776,15 @@ class TextEditor extends Model
# Remove any {Fold}s found that intersect the given buffer row.
destroyFoldsIntersectingBufferRange: (bufferRange) ->
@unfoldBufferRow(bufferRange.start.row)
@unfoldBufferRow(bufferRange.end.row)
@destroyFoldsContainingBufferRange(bufferRange)
for row in [bufferRange.end.row..bufferRange.start.row]
fold.destroy() for fold in @displayBuffer.foldsStartingAtBufferRow(row)
destroyFoldsContainingBufferRange: (bufferRange) ->
@unfoldBufferRow(bufferRange.start.row)
@unfoldBufferRow(bufferRange.end.row)
# {Delegates to: DisplayBuffer.largestFoldContainingBufferRow}
largestFoldContainingBufferRow: (bufferRow) ->
@displayBuffer.largestFoldContainingBufferRow(bufferRow)