Esempio n. 1
0
 // Token: 0x0600625B RID: 25179 RVA: 0x001B9470 File Offset: 0x001B7670
 private static TextSegment CreateNormalizedSegment(ITextPointer start, ITextPointer end)
 {
     if (start.CompareTo(end) == 0)
     {
         if (!TextPointerBase.IsAtInsertionPosition(start, start.LogicalDirection))
         {
             start = start.GetInsertionPosition(start.LogicalDirection);
             end   = start;
         }
     }
     else
     {
         if (!TextPointerBase.IsAtInsertionPosition(start, start.LogicalDirection))
         {
             start = start.GetInsertionPosition(LogicalDirection.Forward);
         }
         if (!TextPointerBase.IsAtInsertionPosition(end, start.LogicalDirection))
         {
             end = end.GetInsertionPosition(LogicalDirection.Backward);
         }
         if (start.CompareTo(end) >= 0)
         {
             if (start.LogicalDirection == LogicalDirection.Backward)
             {
                 start = end.GetFrozenPointer(LogicalDirection.Backward);
             }
             end = start;
         }
     }
     return(new TextSegment(start, end));
 }
Esempio n. 2
0
        /// <summary>
        /// Creates a new segment with the specified pointers, but first
        /// normalizes them to make sure they are on insertion positions.
        /// </summary>
        /// <param name="start">start of the new segment</param>
        /// <param name="end">end of the new segment</param>
        private static TextSegment CreateNormalizedSegment(ITextPointer start, ITextPointer end)
        {
            // Normalize the segment
            if (start.CompareTo(end) == 0)
            {
                // When the range is empty we must keep it that way during normalization
                if (!TextPointerBase.IsAtInsertionPosition(start, start.LogicalDirection))
                {
                    start = start.GetInsertionPosition(start.LogicalDirection);
                    end   = start;
                }
            }
            else
            {
                if (!TextPointerBase.IsAtInsertionPosition(start, start.LogicalDirection))
                {
                    start = start.GetInsertionPosition(LogicalDirection.Forward);
                }
                if (!TextPointerBase.IsAtInsertionPosition(end, start.LogicalDirection))
                {
                    end = end.GetInsertionPosition(LogicalDirection.Backward);
                }

                // Collapse range in case of overlapped normalization result
                if (start.CompareTo(end) >= 0)
                {
                    // The range is effectuvely empty, so collapse it to single pointer instance
                    if (start.LogicalDirection == LogicalDirection.Backward)
                    {
                        // Choose a position normalized backward,
                        start = end.GetFrozenPointer(LogicalDirection.Backward);

                        // NOTE that otherwise we will use start position,
                        // which is oriented and normalizd Forward
                    }
                    end = start;
                }
            }

            return(new TextSegment(start, end));
        }