       @updateDisplayBuffer() unless newRange.isEqual(oldRange)
     @marker.on 'destroyed', => @destroyed()
 
-  updateDisplayBuffer: ->
-    unless @isInsideLargerFold()
-      @displayBuffer.updateScreenLines(@getStartRow(), @getEndRow(), 0, updateMarkers: true)
-
+  # Returns whether this fold is contained within another fold
   isInsideLargerFold: ->
     @displayBuffer.findMarker(class: 'fold', containsBufferRange: @getBufferRange())?
 
+  # Destroys this fold
   destroy: ->
     @marker.destroy()
 
+  # Returns the fold's {Range} in buffer coordinates
   getBufferRange: ->
     @marker.getBufferRange()
 
+  # Returns the fold's start row as a {Number}.
   getStartRow: ->
     @getBufferRange().start.row
 
+  # Returns the fold's end row as a {Number}.
   getEndRow: ->
     @getBufferRange().end.row
 
+  # Returns a {String} representation of the fold.
   inspect: ->
     "Fold(#{@getStartRow()}, #{@getEndRow()})"
 

Range = require 'range'
Point = require 'point'

# Public: Represents a fold that's hiding text from the screen.
#
# Folds are the primary reason that screen ranges and buffer ranges vary. Their
# creation is managed by the {DisplayBuffer}.
module.exports =
class Fold
  displayBuffer: null
  marker: null

  constructor: (@displayBuffer, @marker) ->
    @displayBuffer.foldsByMarkerId[@marker.id] = this
    @updateDisplayBuffer()


  ## Internal ##

  updateDisplayBuffer: ->
    unless @isInsideLargerFold()
      @displayBuffer.updateScreenLines(@getStartRow(), @getEndRow(), 0, updateMarkers: true)

  destroyed: ->
    delete @displayBuffer.foldsByMarkerId[@marker.id]
    @updateDisplayBuffer()
