11using System ;
2- using System . Windows ;
32using System . ComponentModel . Composition ;
43using GitHub . Commands ;
54using GitHub . Services ;
6- using GitHub . App . Services ;
75using GitHub . Services . Vssdk . Commands ;
86using Task = System . Threading . Tasks . Task ;
97
@@ -12,8 +10,11 @@ namespace GitHub.VisualStudio.Commands
1210 [ Export ( typeof ( IOpenFromClipboardCommand ) ) ]
1311 public class OpenFromClipboardCommand : VsCommand < string > , IOpenFromClipboardCommand
1412 {
15- readonly Lazy < GitHubContextService > gitHubContextService ;
13+ public const string NoGitHubUrlMessage = "Couldn't a find a GitHub URL in clipboard" ;
14+
15+ readonly Lazy < IGitHubContextService > gitHubContextService ;
1616 readonly Lazy < ITeamExplorerContext > teamExplorerContext ;
17+ readonly Lazy < IVSServices > vsServices ;
1718
1819 /// <summary>
1920 /// Gets the GUID of the group the command belongs to.
@@ -27,28 +28,25 @@ public class OpenFromClipboardCommand : VsCommand<string>, IOpenFromClipboardCom
2728
2829 [ ImportingConstructor ]
2930 public OpenFromClipboardCommand (
30- Lazy < GitHubContextService > gitHubContextService ,
31- Lazy < ITeamExplorerContext > teamExplorerContext )
31+ Lazy < IGitHubContextService > gitHubContextService ,
32+ Lazy < ITeamExplorerContext > teamExplorerContext ,
33+ Lazy < IVSServices > vsServices )
3234 : base ( CommandSet , CommandId )
3335 {
3436 this . gitHubContextService = gitHubContextService ;
3537 this . teamExplorerContext = teamExplorerContext ;
38+ this . vsServices = vsServices ;
3639
3740 // See https://code.msdn.microsoft.com/windowsdesktop/AllowParams-2005-9442298f
3841 ParametersDescription = "u" ; // accept a single url
3942 }
4043
4144 public override Task Execute ( string url )
4245 {
43- if ( string . IsNullOrEmpty ( url ) )
44- {
45- url = Clipboard . GetText ( TextDataFormat . Text ) ;
46- }
47-
48- var context = gitHubContextService . Value . FindContextFromUrl ( url ) ;
46+ var context = gitHubContextService . Value . FindContextFromClipboard ( ) ;
4947 if ( context == null )
5048 {
51- // Couldn't find URL in clipboard
49+ vsServices . Value . ShowMessageBoxInfo ( NoGitHubUrlMessage ) ;
5250 return Task . CompletedTask ;
5351 }
5452
0 commit comments