mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Destroy only containing folds on selection
This commit is contained in:
@@ -100,7 +100,7 @@ class Selection extends Model
|
||||
bufferRange = Range.fromObject(bufferRange)
|
||||
@needsAutoscroll = options.autoscroll
|
||||
options.reversed ?= @isReversed()
|
||||
@editor.destroyFoldsIntersectingBufferRange(bufferRange) unless options.preserveFolds
|
||||
@editor.destroyFoldsContainingBufferRange(bufferRange) unless options.preserveFolds
|
||||
@modifySelection =>
|
||||
needsFlash = options.flash
|
||||
delete options.flash if options.flash?
|
||||
@@ -251,8 +251,7 @@ class Selection extends Model
|
||||
|
||||
# Public: Selects all the text in the buffer.
|
||||
selectAll: ->
|
||||
@editor.unfoldAll()
|
||||
@setBufferRange(@editor.buffer.getRange(), autoscroll: false, preserveFolds: true)
|
||||
@setBufferRange(@editor.buffer.getRange(), autoscroll: false)
|
||||
|
||||
# Public: Selects all the text from the current cursor position to the
|
||||
# beginning of the line.
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user