     @insert(@getEndPosition(), text, options)
 
   # Applies a change to the buffer based on its old range and new text.
-  applyChange: (change) ->
-    {newStart, oldExtent, newExtent, oldText, newText, normalizeLineEndings} = change
+  applyChange: (change, pushToHistory = false) ->
+    {newStart, oldExtent, oldText, newText, normalizeLineEndings} = change
+    @cachedText = null
+
     start = Point.fromObject(newStart)
     oldRange = Range(start, start.traverse(oldExtent))
-    newRange = Range(start, start.traverse(newExtent))
     oldRange.freeze()
-    newRange.freeze()
-    @cachedText = null
-
     startRow = oldRange.start.row
     endRow = oldRange.end.row
     rowCount = endRow - startRow + 1


    @changeCount++
    @emitDidChangeEvent(changeEvent)

  emitDidChangeEvent: (changeEvent) ->
    # 1. Emit the change event on all the registered text decoration layers.

    lineEndings.push('')
    normalizedNewText += lastLine

    newExtent = Point(lines.length - 1, lastLine.length)
    newRange = Range(start, start.traverse(newExtent))
    newRange.freeze()

    if pushToHistory
      change.newExtent ?= newExtent
      @history?.pushChange(change)

    newText = normalizedNewText
    changeEvent = Object.freeze({oldRange, newRange, oldText, newText})
    for id, displayLayer of @displayLayers
