Example #1
0
        /// <summary>
        /// Shifts node components that are located at or beyond given start point by the specified range
        /// </summary>
        /// <param name="start">Start point</param>
        /// <param name="offset">Offset to shift by</param>
        public override void ShiftStartingFrom(int start, int offset)
        {
            // short-circuit in the case where the shift starts after our end
            if (start > End)
            {
                return;
            }

            // if tag is not closed and change is right at the end,
            // e need to grow start tag rather than element inner range

            if (StartTag.Contains(start) || StartTag.Start >= start || (!StartTag.IsClosed && start == StartTag.End))
            {
                StartTag.ShiftStartingFrom(start, offset);
            }

            if (EndTag != null && (EndTag.Contains(start) || EndTag.Start >= start))
            {
                EndTag.ShiftStartingFrom(start, offset);
            }

            if (OrphanedEndTagsCollection != null)
            {
                OrphanedEndTagsCollection.ShiftStartingFrom(start, offset);
            }

            if (VirtualEnd >= start)
            {
                VirtualEnd = Math.Max(start, VirtualEnd + offset);
            }

            int count = Children.Count;

            for (int i = 0; i < count; i++)
            {
                Children[i].ShiftStartingFrom(start, offset);
            }
        }