@@ -26,11 +26,13 @@ public class GitHubContextService
2626
2727 const string issue = "(?<issue>[0-9]+)" ;
2828
29+ static readonly string path = $ "^{ repo } /(?<path>[^ ]+)";
30+
2931 static readonly Regex windowTitleRepositoryRegex = new Regex ( $ "^{ owner } /{ repo } : ", RegexOptions . Compiled ) ;
3032 static readonly Regex windowTitleBranchRegex = new Regex ( $ "^{ owner } /{ repo } at { branch } ", RegexOptions . Compiled ) ;
3133 static readonly Regex windowTitlePullRequestRegex = new Regex ( $ " · Pull Request #{ pull } · { owner } /{ repo } - ", RegexOptions . Compiled ) ;
3234 static readonly Regex windowTitleIssueRegex = new Regex ( $ " · Issue #{ issue } · { owner } /{ repo } - ", RegexOptions . Compiled ) ;
33- static readonly Regex windowTitlePathRegex = new Regex ( $ " at { branch } · { owner } /{ repo } - ", RegexOptions . Compiled ) ;
35+ static readonly Regex windowTitlePathRegex = new Regex ( $ "{ path } at { branch } · { owner } /{ repo } - ", RegexOptions . Compiled ) ;
3436 static readonly Regex windowTitleBranchesRegex = new Regex ( $ "Branches · { owner } /{ repo } - ", RegexOptions . Compiled ) ;
3537
3638 public GitHubContext FindContextFromUrl ( UriString url )
@@ -68,7 +70,7 @@ public IEnumerable<string> FindWindowTitlesForClass(string className = "Chrome_W
6870
6971 public GitHubContext FindContextFromWindowTitle ( string windowTitle )
7072 {
71- var ( success , owner , repo , branch , pullRequest , issue ) = MatchWindowTitle ( windowTitle ) ;
73+ var ( success , owner , repo , branch , pullRequest , issue , path ) = MatchWindowTitle ( windowTitle ) ;
7274 if ( ! success )
7375 {
7476 return null ;
@@ -80,51 +82,52 @@ public GitHubContext FindContextFromWindowTitle(string windowTitle)
8082 RepositoryName = repo ,
8183 Branch = branch ,
8284 PullRequest = pullRequest ,
83- Issue = issue
85+ Issue = issue ,
86+ Path = path
8487 } ;
8588 }
8689
87- static ( bool success , string owner , string repo , string branch , int ? pullRequest , int ? issue ) MatchWindowTitle ( string windowTitle )
90+ static ( bool success , string owner , string repo , string branch , int ? pullRequest , int ? issue , string path ) MatchWindowTitle ( string windowTitle )
8891 {
8992 var match = windowTitlePathRegex . Match ( windowTitle ) ;
9093 if ( match . Success )
9194 {
92- return ( match . Success , match . Groups [ "owner" ] . Value , match . Groups [ "repo" ] . Value , match . Groups [ "branch" ] . Value , null , null ) ;
95+ return ( match . Success , match . Groups [ "owner" ] . Value , match . Groups [ "repo" ] . Value , match . Groups [ "branch" ] . Value , null , null , match . Groups [ "path" ] . Value ) ;
9396 }
9497
9598 match = windowTitleRepositoryRegex . Match ( windowTitle ) ;
9699 if ( match . Success )
97100 {
98- return ( match . Success , match . Groups [ "owner" ] . Value , match . Groups [ "repo" ] . Value , null , null , null ) ;
101+ return ( match . Success , match . Groups [ "owner" ] . Value , match . Groups [ "repo" ] . Value , null , null , null , null ) ;
99102 }
100103
101104 match = windowTitleBranchRegex . Match ( windowTitle ) ;
102105 if ( match . Success )
103106 {
104- return ( match . Success , match . Groups [ "owner" ] . Value , match . Groups [ "repo" ] . Value , match . Groups [ "branch" ] . Value , null , null ) ;
107+ return ( match . Success , match . Groups [ "owner" ] . Value , match . Groups [ "repo" ] . Value , match . Groups [ "branch" ] . Value , null , null , null ) ;
105108 }
106109
107110 match = windowTitleBranchesRegex . Match ( windowTitle ) ;
108111 if ( match . Success )
109112 {
110- return ( match . Success , match . Groups [ "owner" ] . Value , match . Groups [ "repo" ] . Value , null , null , null ) ;
113+ return ( match . Success , match . Groups [ "owner" ] . Value , match . Groups [ "repo" ] . Value , null , null , null , null ) ;
111114 }
112115
113116 match = windowTitlePullRequestRegex . Match ( windowTitle ) ;
114117 if ( match . Success )
115118 {
116119 int . TryParse ( match . Groups [ "pull" ] . Value , out int pullRequest ) ;
117- return ( match . Success , match . Groups [ "owner" ] . Value , match . Groups [ "repo" ] . Value , null , pullRequest , null ) ;
120+ return ( match . Success , match . Groups [ "owner" ] . Value , match . Groups [ "repo" ] . Value , null , pullRequest , null , null ) ;
118121 }
119122
120123 match = windowTitleIssueRegex . Match ( windowTitle ) ;
121124 if ( match . Success )
122125 {
123126 int . TryParse ( match . Groups [ "issue" ] . Value , out int issue ) ;
124- return ( match . Success , match . Groups [ "owner" ] . Value , match . Groups [ "repo" ] . Value , null , null , issue ) ;
127+ return ( match . Success , match . Groups [ "owner" ] . Value , match . Groups [ "repo" ] . Value , null , null , issue , null ) ;
125128 }
126129
127- return ( match . Success , null , null , null , null , null ) ;
130+ return ( match . Success , null , null , null , null , null , null ) ;
128131 }
129132
130133 static class User32
0 commit comments