anchor.diff:                              // exit without setting the closing point which will take us off the stack
                               edit.Cancel()
                               undo.Cancel()
  -                            snapshot
  +                            None
                           else
  -                            edit.Apply() // FIXME: perhaps, it should be ApplyAndLogExceptions()
  -
  -                    let beforePoint = beforeTrackingPoint.GetPoint(textView.TextSnapshot)
  -
  -                    // switch from positive to negative tracking so it stays against the closing brace
  -                    closingPoint <- subjectBuffer.CurrentSnapshot.CreateTrackingPoint(closingPoint.GetPoint(snapshot).Position, PointTrackingMode.Negative)
  -
  -                    Debug.Assert(closingPoint.GetPoint(snapshot).Position > 0 && (SnapshotSpan(closingPoint.GetPoint(snapshot).Subtract(1), 1)).GetText().Equals(closingBrace.ToString()),
  -                        "The closing point does not match the closing brace character")
  -
  -                    // move the caret back between the braces
  -                    textView.Caret.MoveTo(beforePoint) |> ignore
  -
  -                    session.AfterStart(this, cancellationToken)
  -
  -                    undo.Complete()
  +                            Some(edit.Apply()) // FIXME: perhaps, it should be ApplyAndLogExceptions()
  +
  +                    match nextSnapshot with
  +                    | None -> ()
  +                    | Some(nextSnapshot) ->
  +
  +                        let beforePoint = beforeTrackingPoint.GetPoint(textView.TextSnapshot)
  +
  +                        // switch from positive to negative tracking so it stays against the closing brace
  +                        closingPoint <- subjectBuffer.CurrentSnapshot.CreateTrackingPoint(closingPoint.GetPoint(nextSnapshot).Position, PointTrackingMode.Negative)
  +
  +                        Debug.Assert(closingPoint.GetPoint(nextSnapshot).Position > 0 && (SnapshotSpan(closingPoint.GetPoint(nextSnapshot).Subtract(1), 1)).GetText().Equals(closingBrace.ToString()),
  +                            "The closing point does not match the closing brace character")
  +
  +                        // move the caret back between the braces
  +                        textView.Caret.MoveTo(beforePoint) |> ignore
  +
  +                        session.AfterStart(this, cancellationToken)
  +
  +                        undo.Complete()
   
       member __.HasNoForwardTyping(caretPoint: SnapshotPoint, endPoint: SnapshotPoint) =
           Debug.Assert(caretPoint.Snapshot = endPoint.Snapshot, "snapshots do not match")
  
positive.code: 
                  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
                      // ensure that we are within the session before clearing
                      | Some caretPos when caretPos.Position < closingSnapshotPoint.Position && closingSnapshotPoint.Position > 0 ->
                          use undo = this.CreateUndoTransaction()
  
                          let span = SnapshotSpan(caretPos, closingSnapshotPoint.Subtract(1))
  
  
negative.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()
                      let nextSnapshot =
                          use edit = subjectBuffer.CreateEdit()
  
                          edit.Insert(closingSnapshotPoint.Position, closingBrace.ToString()) |> ignore
  