Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit ce68103

Browse files
committed
Lazy initialize the UIContext
This broke unit tests and probably should be done on UI thread.
1 parent bec5eca commit ce68103

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/GitHub.VisualStudio/Commands/OpenFromClipboardCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class OpenFromClipboardCommand : VsCommand<string>, IOpenFromClipboardCom
2424
readonly Lazy<IGitHubContextService> gitHubContextService;
2525
readonly Lazy<ITeamExplorerContext> teamExplorerContext;
2626
readonly Lazy<IVSServices> vsServices;
27-
readonly UIContext uiContext;
27+
readonly Lazy<UIContext> uiContext;
2828

2929
/// <summary>
3030
/// Gets the GUID of the group the command belongs to.
@@ -51,7 +51,7 @@ public OpenFromClipboardCommand(
5151
ParametersDescription = "u"; // accept a single url
5252

5353
// This command is only visible when in the context of a Git repository
54-
uiContext = UIContext.FromUIContextGuid(new Guid(Guids.UIContext_Git));
54+
uiContext = new Lazy<UIContext>(() => UIContext.FromUIContextGuid(new Guid(Guids.UIContext_Git)));
5555
}
5656

5757
public override async Task Execute(string url)
@@ -118,7 +118,7 @@ public override async Task Execute(string url)
118118

119119
protected override void QueryStatus()
120120
{
121-
Visible = uiContext.IsActive;
121+
Visible = uiContext.Value.IsActive;
122122
}
123123
}
124124
}

0 commit comments

Comments
 (0)