예제 #1
0
        void HandleBackgroundParseComplete(object sender, ParseResultEventArgs e)
        {
            MarkdownParseResultEventArgs args        = e as MarkdownParseResultEventArgs;
            List <MarkdownSection>       newSections = args != null ? args.Sections : new List <MarkdownSection>();
            Action updateAction = () => RefreshComboItems(textView.TextBuffer.CurrentSnapshot, args.Sections);

            Dispatcher.BeginInvoke(updateAction);
        }
예제 #2
0
        private void HandleBackgroundParseComplete(object sender, ParseResultEventArgs e)
        {
            MarkdownParseResultEventArgs args        = e as MarkdownParseResultEventArgs;
            List <MarkdownSection>       newSections = args != null ? args.Sections : new List <MarkdownSection>();

            ITextSnapshot snapshot = e.Snapshot;
            NormalizedSnapshotSpanCollection oldSectionSpans = new NormalizedSnapshotSpanCollection(
                _sections.Select(s => s.Span.GetSpan(snapshot)));
            NormalizedSnapshotSpanCollection newSectionSpans = new NormalizedSnapshotSpanCollection(
                newSections.Select(s => s.Span.GetSpan(snapshot)));

            NormalizedSnapshotSpanCollection difference = SymmetricDifference(oldSectionSpans, newSectionSpans);

            Action updateAction = () =>
            {
                try
                {
                    _sections = newSections;
                    foreach (var span in difference)
                    {
                        var temp = TagsChanged;
                        if (temp != null)
                        {
                            temp(this, new SnapshotSpanEventArgs(span));
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (ErrorHandler.IsCriticalException(ex))
                    {
                        throw;
                    }
                }
            };

            _dispatcher.BeginInvoke(updateAction);
        }