From 16d5b770f522e451bb2438bb40ed861e6a68f167 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 6 Feb 2023 17:08:42 -0500 Subject: [PATCH] Adds a modal to worktree creation flow --- src/commands/git/worktree.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/commands/git/worktree.ts b/src/commands/git/worktree.ts index b8fb34a..226c01e 100644 --- a/src/commands/git/worktree.ts +++ b/src/commands/git/worktree.ts @@ -322,6 +322,7 @@ export class WorktreeGitCommand extends QuickCommand { icon: false, label: state.reference.refType !== 'branch', })}`, + defaultUri: context.defaultUri, }); if (result === StepResult.Break) continue; @@ -478,21 +479,28 @@ export class WorktreeGitCommand extends QuickCommand { private async *createCommandChoosePathStep( state: CreateStepState, context: Context, - options?: { titleContext?: string }, + options: { titleContext: string; defaultUri?: Uri }, ): AsyncStepResultGenerator { const step = QuickCommand.createCustomStep({ show: async (_step: CustomStep) => { + const hasDefault = options?.defaultUri != null; + const result = await window.showInformationMessage( + `Choose a location in which to create the worktree${options.titleContext}.`, + { modal: true }, + { title: 'Choose Location' }, + ...(hasDefault ? [{ title: 'Use Default Location' }] : []), + ); + + if (result == null) return Directive.Back; + if (result.title === 'Use Default Location') return options.defaultUri!; + const uris = await window.showOpenDialog({ canSelectFiles: false, canSelectFolders: true, canSelectMany: false, defaultUri: context.pickedUri ?? state.uri ?? context.defaultUri, openLabel: 'Select Worktree Location', - title: `${appendReposToTitle( - `Choose Worktree Location${options?.titleContext ?? ''}`, - state, - context, - )}`, + title: `${appendReposToTitle(`Choose a Worktree Location${options.titleContext}`, state, context)}`, }); if (uris == null || uris.length === 0) return Directive.Back;