From 5161ebaf8a5228e9ec6cff74f1248f7e4fbefcc4 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Mon, 31 Jul 2017 17:27:04 -0700 Subject: [PATCH] Enables the Razor Document Tracker This enables the tracking of events that change the 'razor' state of a document that's open in the editor. Also fixed a crash that can occur when creating a new project with the Razor Info window open. --- .../DefaultTextViewRazorDocumentTrackerService.cs | 3 +-- .../DocumentInfo/RazorDocumentInfoWindow.cs | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTextViewRazorDocumentTrackerService.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTextViewRazorDocumentTrackerService.cs index 9c618e6702..250081cb20 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTextViewRazorDocumentTrackerService.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultTextViewRazorDocumentTrackerService.cs @@ -16,8 +16,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor { [ContentType(RazorLanguage.ContentType)] [TextViewRole(PredefinedTextViewRoles.Editable)] - //[Export(typeof(IWpfTextViewConnectionListener))] - we're not exporting this interface because we only want it to be hooked up - // in developer mode. + [Export(typeof(IWpfTextViewConnectionListener))] [Export(typeof(TextViewRazorDocumentTrackerService))] internal class DefaultTextViewRazorDocumentTrackerService : TextViewRazorDocumentTrackerService, IWpfTextViewConnectionListener { diff --git a/tooling/Microsoft.VisualStudio.RazorExtension/DocumentInfo/RazorDocumentInfoWindow.cs b/tooling/Microsoft.VisualStudio.RazorExtension/DocumentInfo/RazorDocumentInfoWindow.cs index d1ee82030b..9d51d88ad0 100644 --- a/tooling/Microsoft.VisualStudio.RazorExtension/DocumentInfo/RazorDocumentInfoWindow.cs +++ b/tooling/Microsoft.VisualStudio.RazorExtension/DocumentInfo/RazorDocumentInfoWindow.cs @@ -63,6 +63,10 @@ namespace Microsoft.VisualStudio.RazorExtension.DocumentInfo private void OnBeforeDocumentWindowShow(IVsWindowFrame frame) { var vsTextView = VsShellUtilities.GetTextView(frame); + if (vsTextView == null) + { + return; + } var textView = _adapterFactory.GetWpfTextView(vsTextView); if (textView != null && textView != _textView)