File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11901190 "title" : " %command.pr.acceptMerge.title%" ,
11911191 "category" : " %command.pull.request.category%"
11921192 },
1193+ {
1194+ "command" : " pr.closeRelatedEditors" ,
1195+ "title" : " %command.pr.closeRelatedEditors.title%" ,
1196+ "category" : " %command.pull.request.category%"
1197+ },
11931198 {
11941199 "command" : " review.diffWithPrHead" ,
11951200 "title" : " %command.review.diffWithPrHead.title%" ,
17761781 "command" : " pr.showDiffAll" ,
17771782 "when" : " false"
17781783 },
1784+ {
1785+ "command" : " pr.closeRelatedEditors" ,
1786+ "when" : " gitHubOpenRepositoryCount != 0"
1787+ },
17791788 {
17801789 "command" : " review.suggestDiff" ,
17811790 "when" : " false"
29082917 "group" : " 1_cutcopypaste@0"
29092918 }
29102919 ],
2920+ "editor/title/context" : [
2921+ {
2922+ "command" : " pr.closeRelatedEditors" ,
2923+ "when" : " resourceScheme == 'pr' || resourceScheme == 'review' || resourcePath in github:unviewedFiles || resourcePath in github:viewedFiles" ,
2924+ "group" : " 1_close@60"
2925+ }
2926+ ],
29112927 "editor/title/context/share" : [
29122928 {
29132929 "command" : " issue.copyGithubPermalinkWithoutRange" ,
Original file line number Diff line number Diff line change 255255 "command.pr.refreshComments.title" : " Refresh Pull Request Comments" ,
256256 "command.pr.resolveConflict.title" : " Resolve Conflict" ,
257257 "command.pr.acceptMerge.title" : " Accept Merge" ,
258+ "command.pr.closeRelatedEditors.title" : " Close All Pull Request Editors" ,
258259 "command.issue.copyGithubDevLink.title" : " Copy github.dev Link" ,
259260 "command.issue.copyGithubPermalink.title" : " Copy GitHub Permalink" ,
260261 "command.issue.copyGithubHeadLink.title" : " Copy GitHub Head Link" ,
Original file line number Diff line number Diff line change @@ -129,6 +129,18 @@ export async function openPullRequestOnGitHub(e: PRNode | DescriptionNode | Pull
129129 telemetry . sendTelemetryEvent ( 'pr.openInGitHub' ) ;
130130}
131131
132+ export async function closeAllPrAndReviewEditors ( ) {
133+ const tabs = vscode . window . tabGroups ;
134+ const editors = tabs . all . map ( group => group . tabs ) . flat ( ) ;
135+
136+ for ( const tab of editors ) {
137+ const scheme = tab . input instanceof vscode . TabInputTextDiff ? tab . input . original . scheme : ( tab . input instanceof vscode . TabInputText ? tab . input . uri . scheme : undefined ) ;
138+ if ( scheme && ( scheme === Schemes . Pr ) || ( scheme === Schemes . Review ) ) {
139+ await tabs . close ( tab ) ;
140+ }
141+ }
142+ }
143+
132144export function registerCommands (
133145 context : vscode . ExtensionContext ,
134146 reposManager : RepositoriesManager ,
@@ -1614,4 +1626,8 @@ ${contents}
16141626 }
16151627 }
16161628 } ) ) ;
1629+
1630+ context . subscriptions . push (
1631+ vscode . commands . registerCommand ( 'pr.closeRelatedEditors' , closeAllPrAndReviewEditors )
1632+ ) ;
16171633}
You can’t perform that action at this time.
0 commit comments