diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index e41a8161c56..2e83594e45b 100755 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -496,6 +496,7 @@ export class CommandCenter { @command('git.init') async init(): Promise { let repositoryPath: string | undefined = undefined; + let askToOpen = true; if (workspace.workspaceFolders) { const placeHolder = localize('init', "Pick workspace folder to initialize git repo in"); @@ -510,6 +511,7 @@ export class CommandCenter { return; } else if (item.folder) { repositoryPath = item.folder.uri.fsPath; + askToOpen = false; } } @@ -543,6 +545,10 @@ export class CommandCenter { } repositoryPath = uri.fsPath; + + if (workspace.workspaceFolders && workspace.workspaceFolders.some(w => w.uri.toString() === uri.toString())) { + askToOpen = false; + } } await this.git.init(repositoryPath); @@ -552,6 +558,10 @@ export class CommandCenter { const open = localize('openrepo', "Open Repository"); choices.push(open); + if (!askToOpen) { + return; + } + const addToWorkspace = localize('add', "Add to Workspace"); if (workspace.workspaceFolders) { message = localize('proposeopen2 init', "Would you like to open the initialized repository, or add it to the current workspace?");