diff --git a/src/EditorFeatures/Core/Implementation/Classification/SemanticClassificationViewTaggerProvider.cs b/src/EditorFeatures/Core/Implementation/Classification/SemanticClassificationViewTaggerProvider.cs index de18e615595f50a5478cfc5324ec61075b029d8b..df686d119f85f7008c407100baa0062510cd1625 100644 --- a/src/EditorFeatures/Core/Implementation/Classification/SemanticClassificationViewTaggerProvider.cs +++ b/src/EditorFeatures/Core/Implementation/Classification/SemanticClassificationViewTaggerProvider.cs @@ -92,8 +92,15 @@ protected override Task ProduceTagsAsync(TaggerContext conte var spanToTag = context.SpansToTag.Single(); - _classificationService = _classificationService ?? - spanToTag.Document?.Project.LanguageServices.GetService(); + // Attempt to get a classification service which will actually produce the results. + // If we can't (because we have no Document, or because the language doesn't support + // this service), then bail out immediately. + if (_classificationService == null) + { + var document = spanToTag.Document; + _classificationService = document?.Project.LanguageServices.GetService(); + } + if (_classificationService == null) { return SpecializedTasks.EmptyTask;