From d19504444fe80fc4bfa1c29cd8505c95d3608cb9 Mon Sep 17 00:00:00 2001 From: Kevin Pilch-Bisson Date: Mon, 28 Mar 2016 19:00:00 -0700 Subject: [PATCH] Don't disconnect and reconnect to the same workspace. This hopefully fixes #9723, because there won't be the chance that the WorkspaceRegistrationChanged event will fire *after* the first TagsChanged instead of before. --- ...tacticClassificationTaggerProvider.TagComputer.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.cs b/src/EditorFeatures/Core/Implementation/Classification/SyntacticClassificationTaggerProvider.TagComputer.cs index e591e67d4c6..616fe82c171 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) { -- GitLab