/// <summary>
        /// Method calculates the span from the start of the editor changes and until the end of TagSpans
        /// </summary>
        private SnapshotSpan CalculateSpanOfChanges(INormalizedTextChangeCollection changeCollection, ITextSnapshot newTextSnapshot)
        {
            var startSpans = changeCollection.Select(x => x.NewSpan).ToArray();
            var endSpans   = TagSpans.Select(x => x.Span.Span);

            return(CalculateAffectedSpan(newTextSnapshot, startSpans, endSpans));
        }
            private IReadOnlyList <TextChangeRange> GetChangeRanges(ITextSnapshot snapshot1, ITextSnapshot snapshot2, bool forward)
            {
                var oldSnapshot = forward ? snapshot1 : snapshot2;
                var newSnapshot = forward ? snapshot2 : snapshot1;

                INormalizedTextChangeCollection changes = null;

                for (var oldVersion = oldSnapshot.Version;
                     oldVersion != newSnapshot.Version;
                     oldVersion = oldVersion.Next)
                {
                    if (oldVersion.Changes.Count != 0)
                    {
                        if (changes != null)
                        {
                            // Oops - more than one "textual" change between these snapshots, bail and try to find smallest changes span
                            //Logger.Log(FunctionId.Workspace_SourceText_GetChangeRanges, s_textLog, snapshot1.Version.VersionNumber, snapshot2.Version.VersionNumber);

                            return(new[] { GetChangeRanges(oldSnapshot.Version, newSnapshot.Version, forward) });
                        }
                        else
                        {
                            changes = oldVersion.Changes;
                        }
                    }
                }

                if (changes == null)
                {
                    return(ImmutableArray.Create <TextChangeRange>());
                }
                else
                {
                    return(ImmutableArray.CreateRange(changes.Select(forward ? s_forwardTextChangeRange : s_backwardTextChangeRange)));
                }
            }