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
This commit is contained in:
Kim Santiago
2022-08-19 12:07:14 -07:00
committed by GitHub
parent cb34b13862
commit c7ce98c4de

View File

@@ -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;