diff --git a/vs-commitizen.Settings/OutputPaneWriter.cs b/vs-commitizen.Settings/OutputPaneWriter.cs
new file mode 100644
index 0000000..bfecb1f
--- /dev/null
+++ b/vs-commitizen.Settings/OutputPaneWriter.cs
@@ -0,0 +1,44 @@
+using System;
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+
+namespace vs_commitizen.Settings
+{
+ public static class OutputPaneWriter
+ {
+ private static Guid panelGuild = new Guid("5BB96421-E33D-40DA-9E8D-C657B7E94C70");
+
+ static IVsOutputWindowPane GetPane()
+ {
+ var outputWindow = Package.GetGlobalService(typeof(SVsOutputWindow)) as IVsOutputWindow;
+ if (outputWindow == null) return null;
+
+ IVsOutputWindowPane pane;
+
+ if (ErrorHandler.Failed(outputWindow.GetPane(ref panelGuild, out pane)) &&
+ (ErrorHandler.Succeeded(outputWindow.CreatePane(ref panelGuild, "vs-commitizen", 1, 1))))
+ {
+ outputWindow.GetPane(ref panelGuild, out pane);
+ }
+
+ ErrorHandler.ThrowOnFailure(pane.Activate());
+
+ return pane;
+ }
+
+ public static void Print(string message)
+ {
+ var pane = GetPane();
+
+ ErrorHandler.ThrowOnFailure(pane.OutputString(message + Environment.NewLine));
+ }
+
+ public static void Print(string str, Exception ex)
+ {
+ var pane = GetPane();
+
+ ErrorHandler.ThrowOnFailure(pane.OutputString(str + "\r\n\r\n" + ex));
+ }
+ }
+}
\ No newline at end of file
diff --git a/vs-commitizen.Settings/vs-commitizen.Settings.csproj b/vs-commitizen.Settings/vs-commitizen.Settings.csproj
index e7954ec..4a52bb9 100644
--- a/vs-commitizen.Settings/vs-commitizen.Settings.csproj
+++ b/vs-commitizen.Settings/vs-commitizen.Settings.csproj
@@ -45,6 +45,7 @@
+
Component
diff --git a/vs-commitizen.vs2015/VsCommitizenNavigationItem.cs b/vs-commitizen.vs2015/VsCommitizenNavigationItem.cs
index eb46d43..ecc6c10 100644
--- a/vs-commitizen.vs2015/VsCommitizenNavigationItem.cs
+++ b/vs-commitizen.vs2015/VsCommitizenNavigationItem.cs
@@ -6,6 +6,7 @@
using System.ComponentModel.Composition;
using System.Drawing;
using System.Threading.Tasks;
+using vs_commitizen.Settings;
using vs_commitizen.vs;
namespace vs_commitizen.vs2015
@@ -37,9 +38,23 @@ private async void GitService_PropertyChanged(object sender, System.ComponentMod
private async System.Threading.Tasks.Task UpdateIsVisibleAsync()
{
- await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
- this.IsVisible = this.gitService?.ActiveRepositories.Count > 0;
- await TaskScheduler.Default;
+ if (VsTaskLibraryHelper.ServiceInstance == null)
+ return;
+
+ try
+ {
+ var joinableTaskFactory = ThreadHelper.JoinableTaskFactory;
+ if (joinableTaskFactory == null)
+ return;
+
+ await joinableTaskFactory.SwitchToMainThreadAsync();
+ this.IsVisible = this.gitService?.ActiveRepositories.Count > 0;
+ await TaskScheduler.Default;
+ }
+ catch (Exception ex)
+ {
+ OutputPaneWriter.Print($"UpdateIsVisibleAsync: {ex}");
+ }
}
public override void Execute()