anchor.diff:  
                   let closingSnapshotPoint = closingPoint.GetPoint(snapshot)
                   if not this.HasForwardTyping && session.AllowOverType(this, cancellationToken) then
  -                    let caretPosOpt = tryGetCaretPosition this
  -
  -                    Debug.Assert(caretPosOpt.IsSome && caretPosOpt.Value.Position < closingSnapshotPoint.Position)
  -
  -                    match caretPosOpt with
  +                    let caretPos = tryGetCaretPosition this
  +
  +                    Debug.Assert(caretPos.IsSome && caretPos.Value.Position < closingSnapshotPoint.Position)
  +
  +                    match caretPos with
                       // ensure that we are within the session before clearing
                       | Some caretPos when caretPos.Position < closingSnapshotPoint.Position && closingSnapshotPoint.Position > 0 ->
                           use undo = this.CreateUndoTransaction()
  +
  +                        editorOperations.AddBeforeTextBufferChangePrimitive()
   
                           let span = SnapshotSpan(caretPos, closingSnapshotPoint.Subtract(1))
   
  
positive.code:                 // Debug.Fail("The opening brace was not found at the expected position.");
                  this.EndSession()
              else
  
                  openingPoint <- snapshot.CreateTrackingPoint(openingSnapshotPoint.Position, PointTrackingMode.Positive)
                  let _document = snapshot.GetOpenDocumentInCurrentContextWithChanges()
  
                  if not (session.CheckOpeningPoint(this, cancellationToken)) then
                      this.EndSession()
                  else
  
                      use undo = this.CreateUndoTransaction()
  
                      snapshot <-
                          use edit = subjectBuffer.CreateEdit()
  
                          edit.Insert(closingSnapshotPoint.Position, closingBrace.ToString()) |> ignore
  
negative.code:             Debug.Fail("The closing point was not found at the expected position.")
              this.EndSession()
          else
              let openingSnapshotPoint = closingSnapshotPoint.Subtract(1)
  
              if openingSnapshotPoint.GetChar() <> openingBrace then
  