1- using Neptuo . Productivity . SnippetManager . Models ;
1+ using Neptuo . Productivity . SnippetManager . Models ;
22using Octokit ;
33using System . Diagnostics ;
44
@@ -67,7 +67,7 @@ private async Task AddStarredRepositoriesAsync(SnippetProviderContext context, G
6767 context . Add ( starredParent ) ;
6868
6969 // Add snippets for starred repositories
70- AddSnippetsForRepositories ( context , starredRepositories , starredParent . Title ) ;
70+ AddSnippetsForRepositories ( context , starredRepositories , title : starredParent . Title ) ;
7171 }
7272 }
7373 }
@@ -86,7 +86,7 @@ private async Task AddOrganizationsRepositoriesAsync(SnippetProviderContext cont
8686 Debug . WriteLine ( $ "GitHub snippets for '{ organization . Login } '") ;
8787 var orgRepositories = await github . Repository . GetAllForOrg ( organization . Login ) ;
8888 Debug . WriteLine ( $ "GitHub snippets downloaded for '{ organization . Login } '") ;
89- AddSnippetsForRepositories ( context , orgRepositories ) ;
89+ AddSnippetsForRepositories ( context , orgRepositories , codeSearchType : "org" ) ;
9090 Debug . WriteLine ( $ "GitHub snippets added for '{ organization . Login } '") ;
9191 }
9292 catch ( ForbiddenException )
@@ -102,23 +102,30 @@ private async Task AddOrganizationsRepositoriesAsync(SnippetProviderContext cont
102102 private async Task AddUserRepositoriesAsync ( SnippetProviderContext context , GitHubClient github )
103103 {
104104 var repositories = await github . Repository . GetAllForUser ( configuration . UserName ) ;
105- AddSnippetsForRepositories ( context , repositories ) ;
105+ AddSnippetsForRepositories ( context , repositories , codeSearchType : "user" ) ;
106106 }
107107
108- private void AddSnippetsForRepositories ( SnippetProviderContext context , IReadOnlyList < Repository > repositories , string ? title = null )
108+ private void AddSnippetsForRepositories ( SnippetProviderContext context , IReadOnlyList < Repository > repositories , string ? title = null , string ? codeSearchType = null )
109109 {
110110 List < SnippetModel > snippets = new List < SnippetModel > ( ) ;
111111
112- SnippetModel ? parent = null ;
113112 foreach ( var repository in repositories )
114113 {
115114 if ( title == null && snippets . Count == 0 )
116115 {
117- parent = new SnippetModel (
116+ context . Add ( new SnippetModel (
118117 title : $ "GitHub - { repository . Owner . Login } ",
119118 text : repository . Owner . HtmlUrl
120- ) ;
121- context . Add ( parent ) ;
119+ ) ) ;
120+
121+ if ( codeSearchType != null )
122+ {
123+ context . Add ( new SnippetModel (
124+ title : $ "GitHub - { repository . Owner . Login } - Code search",
125+ text : $ "https://github.com/search?q={ codeSearchType } :{ repository . Owner . Login } &type=code",
126+ priority : SnippetPriority . Low
127+ ) ) ;
128+ }
122129 }
123130
124131 AddSnippetsForRepository (
0 commit comments