Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions vs-commitizen.Settings/OutputPaneWriter.cs
Original file line number Diff line number Diff line change
@@ -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));
}
}
}
1 change: 1 addition & 0 deletions vs-commitizen.Settings/vs-commitizen.Settings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<Compile Include="Bootstrap.cs" />
<Compile Include="ExtensionRegistry.cs" />
<Compile Include="IoC.cs" />
<Compile Include="OutputPaneWriter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingsGeneral.cs">
<SubType>Component</SubType>
Expand Down
21 changes: 18 additions & 3 deletions vs-commitizen.vs2015/VsCommitizenNavigationItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down