void CreateAnchor()
 {
   if (_document != null)
   {
     LineSegment line = _document.GetLineSegment(Math.Max(0, Math.Min(_location.Line, _document.TotalNumberOfLines - 1)));
     _anchor = line.CreateAnchor(Math.Max(0, Math.Min(_location.Column, line.Length)));
     // after insertion: keep bookmarks after the initial whitespace (see DefaultFormattingStrategy.SmartReplaceLine)
     _anchor.MovementType = AnchorMovementType.AfterInsertion;
     _anchor.Deleted += OnAnchorDeleted;
   }
 }
        void AddAnchor(TextAnchor anchor)
        {
            Debug.Assert(anchor.Line == this);

              if (_anchors == null)
            _anchors = new Utilities.WeakCollection<TextAnchor>();

              _anchors.Add(anchor);
        }
        /// <summary>
        /// Creates a new anchor in the current line.
        /// </summary>
        /// <param name="column">The column.</param>
        /// <returns>The <see cref="TextAnchor"/>.</returns>
        public TextAnchor CreateAnchor(int column)
        {
            if (column < 0 || column > Length)
            throw new ArgumentOutOfRangeException("column");

              TextAnchor anchor = new TextAnchor(this, column);
              AddAnchor(anchor);
              return anchor;
        }
		public void AddDeletedAnchor(TextAnchor anchor)
		{
      if (_removedAnchors == null)
        _removedAnchors = new List<TextAnchor>();
      _removedAnchors.Add(anchor);
		}
 /// <summary>
 /// Creates a new anchor in the current line.
 /// </summary>
 /// <param name="column">The column.</param>
 /// <returns>The <see cref="TextAnchor"/>.</returns>
 public TextAnchor CreateAnchor(int column)
 {
   TextAnchor anchor = new TextAnchor(this, column);
   AddAnchor(anchor);
   return anchor;
 }