diff --git a/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.cs b/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.cs index e591e67d4c617308de844e14cec83dce2ceb9a94..616fe82c1715af6a246d1aa2a5299f7888d14e74 100644 --- a/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.cs +++ b/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.cs @@ -95,9 +95,17 @@ internal partial class TagComputer private void OnWorkspaceRegistrationChanged(object sender, EventArgs e) { - DisconnectFromWorkspace(); - + // We both try to connect synchronously, and register for workspace registration events. + // It's possible (particularly in tests), to connect in the startup path, but then get a + // previously scheduled, but not yet delivered event. Don't bother connecting to the + // same workspace again in that case. var newWorkspace = _workspaceRegistration.Workspace; + if (newWorkspace == _workspace) + { + return; + } + + DisconnectFromWorkspace(); if (newWorkspace != null) {