private void HandleViewChanged(object sender, ViewChangedEventArgs e)
        {
            BackgroundParser = null;
            Tagger = null;
            Tokens3 = null;
            Tokens4 = null;
            Snapshot = null;
            Tree.Dispatcher.Invoke(
                (Action)(() =>
                {
                    try
                    {
                        Tree.Items.Clear();
                    }
                    catch (Exception ex)
                    {
                        if (ErrorHandler.IsCriticalException(ex))
                            throw;
                    }
                }));

            if (e.NewView != null)
            {
                var backgroundParser = BackgroundParserFactoryService.GetBackgroundParser(e.NewView.TextBuffer);
                BackgroundParser = backgroundParser;
                if (backgroundParser != null)
                {
                    Tagger = AstReferenceTaggerProvider.GetAstReferenceTagger(e.NewView.TextBuffer);
                    backgroundParser.ParseComplete += WeakEvents.AsWeak<ParseResultEventArgs>(HandleParseComplete, eh => backgroundParser.ParseComplete -= eh);
                    backgroundParser.RequestParse(false);
                }
            }
        }
        private void OnViewChanged(object sender, ViewChangedEventArgs e)
        {
            BackgroundParser = null;

            if (e.NewView != null)
            {
                var backgroundParser = BackgroundParserFactoryService.GetBackgroundParser(e.NewView.TextBuffer);
                BackgroundParser = backgroundParser;
                if (backgroundParser != null)
                {
                    ToolWindowPane.Caption = "Markdown Preview - ";
                    backgroundParser.ParseComplete += WeakEvents.AsWeak<ParseResultEventArgs>(HandleBackgroundParseComplete, eh => backgroundParser.ParseComplete -= eh);
                    backgroundParser.RequestParse(false);
                }
            }

            CurrentView = e.NewView;

            if (BackgroundParser == null)
            {
                ToolWindowPane.Caption = "Markdown Preview";
                Browser.NavigateToString(EmptyWindowHtml);
            }
        }