11import type { MessageItem } from 'vscode' ;
2- import { QuickInputButtons , Uri , window , workspace } from 'vscode' ;
2+ import { env , QuickInputButtons , Uri , window , workspace } from 'vscode' ;
33import type { Config } from '../../config' ;
44import type { Container } from '../../container' ;
55import { PlusFeatures } from '../../features' ;
6- import { convertOpenFlagsToLocation , reveal , revealInFileExplorer } from '../../git/actions/worktree' ;
6+ import { convertOpenFlagsToLocation , reveal } from '../../git/actions/worktree' ;
77import {
88 WorktreeCreateError ,
99 WorktreeCreateErrorReason ,
@@ -23,7 +23,7 @@ import { createFlagsQuickPickItem } from '../../quickpicks/items/flags';
2323import { configuration } from '../../system/configuration' ;
2424import { basename , isDescendant } from '../../system/path' ;
2525import { pluralize , truncateLeft } from '../../system/string' ;
26- import { openWorkspace } from '../../system/utils' ;
26+ import { openWorkspace , revealInFileExplorer } from '../../system/utils' ;
2727import type { ViewsWithRepositoryFolders } from '../../views/viewBase' ;
2828import type {
2929 AsyncStepResultGenerator ,
@@ -469,12 +469,21 @@ export class WorktreeGitCommand extends QuickCommand<State> {
469469 continue ;
470470 }
471471 } else if ( WorktreeCreateError . is ( ex , WorktreeCreateErrorReason . AlreadyExists ) ) {
472- void window . showErrorMessage (
473- `Unable to create a new worktree in '${ GitWorktree . getFriendlyPath (
474- uri ,
475- ) } ' because the folder already exists and is not empty.`,
476- 'OK' ,
477- ) ;
472+ const confirm : MessageItem = { title : 'OK' } ;
473+ const openFolder : MessageItem = { title : 'Open Folder' } ;
474+ void window
475+ . showErrorMessage (
476+ `Unable to create a new worktree in '${ GitWorktree . getFriendlyPath (
477+ uri ,
478+ ) } ' because the folder already exists and is not empty.`,
479+ confirm ,
480+ openFolder ,
481+ )
482+ . then ( result => {
483+ if ( result === openFolder ) {
484+ void env . openExternal ( uri ) ;
485+ }
486+ } ) ;
478487 } else {
479488 void showGenericErrorMessage (
480489 `Unable to create a new worktree in '${ GitWorktree . getFriendlyPath ( uri ) } .` ,
@@ -835,7 +844,7 @@ export class WorktreeGitCommand extends QuickCommand<State> {
835844 if ( worktree == null ) break ;
836845
837846 if ( state . flags . includes ( '--reveal-explorer' ) ) {
838- void revealInFileExplorer ( worktree ) ;
847+ void revealInFileExplorer ( worktree . uri ) ;
839848 } else {
840849 openWorkspace ( worktree . uri , { location : convertOpenFlagsToLocation ( state . flags ) } ) ;
841850 }
0 commit comments