diff --git a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspaceFixture.cs b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspaceFixture.cs index e385b443745d635d571e1db6e4c01b034774dc97..f7d6762e6ff2ca2a6923059fadf877134f6bedd0 100644 --- a/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspaceFixture.cs +++ b/src/EditorFeatures/TestUtilities/Workspaces/TestWorkspaceFixture.cs @@ -64,7 +64,9 @@ private static void UpdateText(ITextBuffer textBuffer, string text) public void CloseTextView() { - GetWorkspace().Documents.Single().CloseTextView(); + // The standard use for TestWorkspaceFixture is to call this method in the test's dispose to make sure it's ready to be used for + // the next test. But some tests in a test class won't use it, so _workspace might still be null. + _workspace?.Documents.Single().CloseTextView(); // The editor caches TextFormattingRunProperties instances for better perf, but since things like // Brushes are DispatcherObjects, they are tied to the thread they are created on. Since we're going