From c7ce98c4de4ee612b308a88ce81dc699c69b4d74 Mon Sep 17 00:00:00 2001 From: Kim Santiago <31145923+kisantia@users.noreply.github.com> Date: Fri, 19 Aug 2022 12:07:14 -0700 Subject: [PATCH] use default folder or open folder as initial location in new project dialog (#20416) * use default folder or open folder in new project dialog * simplify --- extensions/data-workspace/src/dialogs/newProjectDialog.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions/data-workspace/src/dialogs/newProjectDialog.ts b/extensions/data-workspace/src/dialogs/newProjectDialog.ts index 4a2413ea3d..684db314ba 100644 --- a/extensions/data-workspace/src/dialogs/newProjectDialog.ts +++ b/extensions/data-workspace/src/dialogs/newProjectDialog.ts @@ -193,6 +193,11 @@ export class NewProjectDialog extends DialogBase { width: constants.DefaultInputWidth }).component(); + // use the default save location if it's there + // otherwise, if there's an open folder, set the initial location to that. If there are multiple folders in the workspace, default to the first one + const defaultSaveLocation = defaultProjectSaveLocation(); + locationTextBox.value = defaultSaveLocation?.fsPath ?? vscode.workspace.workspaceFolders?.[0]?.uri.fsPath; + this.register(locationTextBox.onTextChanged(() => { this.model.location = locationTextBox.value!; return locationTextBox.updateProperty('title', locationTextBox.value); @@ -209,7 +214,7 @@ export class NewProjectDialog extends DialogBase { canSelectFiles: false, canSelectFolders: true, canSelectMany: false, - defaultUri: defaultProjectSaveLocation() + defaultUri: locationTextBox.value ? vscode.Uri.file(locationTextBox.value) : undefined }); if (!folderUris || folderUris.length === 0) { return;