mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
fixes #33341
This commit is contained in:
parent
156b5d1beb
commit
5b265e0cab
|
@ -32,6 +32,11 @@
|
|||
"title": "%command.init%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.close",
|
||||
"title": "%command.close%",
|
||||
"category": "Git"
|
||||
},
|
||||
{
|
||||
"command": "git.refresh",
|
||||
"title": "%command.refresh%",
|
||||
|
@ -535,11 +540,6 @@
|
|||
"group": "4_stage",
|
||||
"when": "config.git.enabled && scmProvider == git"
|
||||
},
|
||||
{
|
||||
"command": "git.showOutput",
|
||||
"group": "6_output",
|
||||
"when": "config.git.enabled && scmProvider == git"
|
||||
},
|
||||
{
|
||||
"command": "git.stash",
|
||||
"group": "5_stash",
|
||||
|
@ -554,6 +554,16 @@
|
|||
"command": "git.stashPopLatest",
|
||||
"group": "5_stash",
|
||||
"when": "config.git.enabled && scmProvider == git"
|
||||
},
|
||||
{
|
||||
"command": "git.close",
|
||||
"group": "6_misc",
|
||||
"when": "config.git.enabled && scmProvider == git"
|
||||
},
|
||||
{
|
||||
"command": "git.showOutput",
|
||||
"group": "7_repository",
|
||||
"when": "config.git.enabled && scmProvider == git"
|
||||
}
|
||||
],
|
||||
"scm/resourceGroup/context": [
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"command.clone": "Clone",
|
||||
"command.init": "Initialize Repository",
|
||||
"command.close": "Close Repository",
|
||||
"command.refresh": "Refresh",
|
||||
"command.openChange": "Open Changes",
|
||||
"command.openFile": "Open File",
|
||||
|
|
|
@ -330,6 +330,11 @@ export class CommandCenter {
|
|||
await this.model.tryOpenRepository(path);
|
||||
}
|
||||
|
||||
@command('git.close', { repository: true })
|
||||
async closeRepository(repository: Repository): Promise<void> {
|
||||
this.model.close(repository);
|
||||
}
|
||||
|
||||
@command('git.openFile')
|
||||
async openFile(arg?: Resource | Uri, ...resourceStates: SourceControlResourceState[]): Promise<void> {
|
||||
const preserveFocus = arg instanceof Resource;
|
||||
|
|
|
@ -159,6 +159,16 @@ export class Model {
|
|||
this._onDidOpenRepository.fire(repository);
|
||||
}
|
||||
|
||||
close(repository: Repository): void {
|
||||
const openRepository = this.getOpenRepository(repository);
|
||||
|
||||
if (!openRepository) {
|
||||
return;
|
||||
}
|
||||
|
||||
openRepository.dispose();
|
||||
}
|
||||
|
||||
async pickRepository(): Promise<Repository | undefined> {
|
||||
if (this.openRepositories.length === 0) {
|
||||
throw new Error(localize('no repositories', "There are no available repositories"));
|
||||
|
@ -180,6 +190,7 @@ export class Model {
|
|||
return liveRepository && liveRepository.repository;
|
||||
}
|
||||
|
||||
private getOpenRepository(repository: Repository): OpenRepository | undefined;
|
||||
private getOpenRepository(sourceControl: SourceControl): OpenRepository | undefined;
|
||||
private getOpenRepository(resourceGroup: SourceControlResourceGroup): OpenRepository | undefined;
|
||||
private getOpenRepository(path: string): OpenRepository | undefined;
|
||||
|
@ -189,6 +200,10 @@ export class Model {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
if (hint instanceof Repository) {
|
||||
return this.openRepositories.filter(r => r.repository === hint)[0];
|
||||
}
|
||||
|
||||
if (typeof hint === 'string') {
|
||||
hint = Uri.file(hint);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue