Focus projects view when New Project is created (#11048)

* Focusing for new project

* Consolidated focus() logic
This commit is contained in:
Benjin Dubishar
2020-06-23 21:08:40 -07:00
committed by GitHub
parent 17621e4df3
commit cf73cf5003
2 changed files with 5 additions and 7 deletions

View File

@@ -88,14 +88,11 @@ export default class MainController implements Disposable {
filter[constants.sqlDatabaseProject] = ['sqlproj'];
let files: Uri[] | undefined = await this.apiWrapper.showOpenDialog({ filters: filter });
const prevCount = this.projectsController.projects.length;
if (files) {
for (const file of files) {
await this.projectsController.openProject(file);
}
await this.projectsController.focusProject(this.projectsController.projects[prevCount]); // focus the first of the newly-opened projects
}
}
catch (err) {
@@ -137,8 +134,10 @@ export default class MainController implements Disposable {
// TODO: what if the selected folder is outside the workspace?
const newProjFolderUri = (selectionResult as Uri[])[0];
const newProjFilePath = await this.projectsController.createNewProject(newProjName as string, newProjFolderUri as Uri);
return this.projectsController.openProject(Uri.file(newProjFilePath));
const newProjFilePath = await this.projectsController.createNewProject(<string>newProjName, newProjFolderUri);
const proj = await this.projectsController.openProject(Uri.file(newProjFilePath));
return proj;
}
catch (err) {
this.apiWrapper.showErrorMessage(getErrorMessage(err));