Skip to content

Commit

Permalink
Visual Studio console should now clear every build
Browse files Browse the repository at this point in the history
  • Loading branch information
ByronMayne committed Jan 21, 2024
1 parent 3b2e505 commit 7e580cf
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using EnvDTE;
using SGF.Diagnostics;
using System;
using System.Linq;
using System.Diagnostics;
using System.IO;
using Constants = EnvDTE.Constants;

namespace SGF.Interop.VisualStudio
Expand All @@ -19,6 +16,13 @@ public class VisualStudioLogEventSink : ILogSink
private readonly OutputWindow? m_outputWindow;
private readonly OutputWindowPane? m_buildOutput;
private readonly OutputWindowPane? m_sourceGeneratorOutput;

private static bool s_clearedOuput;

static VisualStudioLogEventSink()
{
s_clearedOuput = false;
}

/// <summary>
/// Initializes a new instance of an output channel with the
Expand Down Expand Up @@ -57,14 +61,20 @@ internal VisualStudioLogEventSink()
m_sourceGeneratorOutput ??= m_outputWindow.OutputWindowPanes.Add(outputPanelName);

// When adding a pane will will steal focus, we don't want this. So lets force it back to build
foreach(OutputWindowPane pane in m_outputWindow.OutputWindowPanes)
foreach (OutputWindowPane pane in m_outputWindow.OutputWindowPanes)
{
if(string.Equals(BUILD_OUTPUT_PANE_GUID, pane.Guid))
{
pane.Activate();
}
}
}

if(!s_clearedOuput && m_sourceGeneratorOutput != null)
{
s_clearedOuput = true;
m_sourceGeneratorOutput?.Clear();
}
}
catch
{
Expand Down

0 comments on commit 7e580cf

Please sign in to comment.