Git - add command to close other repositories (#200893)

This commit is contained in:
Ladislau Szomoru 2023-12-14 23:36:20 +01:00 committed by GitHub
parent 29a6631393
commit 81207cddf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View file

@ -98,6 +98,12 @@
"category": "Git", "category": "Git",
"enablement": "!operationInProgress" "enablement": "!operationInProgress"
}, },
{
"command": "git.closeOtherRepositories",
"title": "%command.closeOtherRepositories%",
"category": "Git",
"enablement": "!operationInProgress"
},
{ {
"command": "git.refresh", "command": "git.refresh",
"title": "%command.refresh%", "title": "%command.refresh%",
@ -827,6 +833,10 @@
"command": "git.close", "command": "git.close",
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0" "when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
}, },
{
"command": "git.closeOtherRepositories",
"when": "false"
},
{ {
"command": "git.refresh", "command": "git.refresh",
"when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0" "when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0"
@ -1336,8 +1346,13 @@
"scm/sourceControl": [ "scm/sourceControl": [
{ {
"command": "git.close", "command": "git.close",
"group": "navigation", "group": "navigation@1",
"when": "scmProvider == git" "when": "scmProvider == git"
},
{
"command": "git.closeOtherRepositories",
"group": "navigation@2",
"when": "scmProvider == git && gitOpenRepositoryCount > 1"
} }
], ],
"scm/resourceGroup/context": [ "scm/resourceGroup/context": [

View file

@ -9,6 +9,7 @@
"command.openRepository": "Open Repository", "command.openRepository": "Open Repository",
"command.reopenClosedRepositories": "Reopen Closed Repositories...", "command.reopenClosedRepositories": "Reopen Closed Repositories...",
"command.close": "Close Repository", "command.close": "Close Repository",
"command.closeOtherRepositories": "Close Other Repositories",
"command.refresh": "Refresh", "command.refresh": "Refresh",
"command.openChange": "Open Changes", "command.openChange": "Open Changes",
"command.openAllChanges": "Open All Changes", "command.openAllChanges": "Open All Changes",

View file

@ -962,6 +962,16 @@ export class CommandCenter {
this.model.close(repository); this.model.close(repository);
} }
@command('git.closeOtherRepositories', { repository: true })
async closeOtherRepositories(repository: Repository): Promise<void> {
for (const r of this.model.repositories) {
if (r === repository) {
continue;
}
this.model.close(r);
}
}
@command('git.openFile') @command('git.openFile')
async openFile(arg?: Resource | Uri, ...resourceStates: SourceControlResourceState[]): Promise<void> { async openFile(arg?: Resource | Uri, ...resourceStates: SourceControlResourceState[]): Promise<void> {
const preserveFocus = arg instanceof Resource; const preserveFocus = arg instanceof Resource;