       return row - 1
     lastRow
 
-  getRange: (startRow) ->
+  getRange: (selection) ->
+    @getRangeFromRow(selection.getBufferRange().start.row)
+
+  getRangeFromRow: (startRow) ->
     isBlank = @editor.isBufferRowBlank.bind(@editor)
     wasBlank = isBlank(startRow)
     fn = (row) -> isBlank(row) is wasBlank

class Indentation extends Paragraph
  @extend(false)

  getRange: (startRow) ->
    return if @editor.isBufferRowBlank(startRow)
    baseIndentLevel = getIndentLevelForBufferRow(@editor, startRow)
    fn = (row) =>
      if @editor.isBufferRowBlank(row)

  getFoldRowRangesContainsForRow: (row) ->
    getCodeFoldRowRangesContainesForRow(@editor, row, true)?.reverse()

  getRange: (selection) ->
    range = selection.getBufferRange()
    rowRanges = @getFoldRowRangesContainsForRow(range.start.row)
    return unless rowRanges.length

    if (rowRange = rowRanges.shift())?
      rowRange = @adjustRowRange(rowRange)
      targetRange = getBufferRangeForRowRange(@editor, rowRange)
      if targetRange.isEqual(range) and rowRanges.length
        rowRange = @adjustRowRange(rowRanges.shift())

    getBufferRangeForRowRange(@editor, rowRange)

  selectTextObject: (selection) ->
    swrap(selection).setBufferRangeSafely(@getRange(selection))

class AFold extends Fold
  @extend()
