Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[workspace] do not re-open an already currently opened workspace #5632

Merged
merged 1 commit into from
Jul 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions packages/workspace/src/browser/workspace-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi
canSelectFolders: true,
canSelectFiles: true
}, rootStat);
if (destinationUri) {
if (destinationUri && this.getCurrentWorkspaceUri().toString() !== destinationUri.toString()) {
const destination = await this.fileSystem.getFileStat(destinationUri.toString());
if (destination) {
if (destination.isDirectory) {
Expand Down Expand Up @@ -235,7 +235,8 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi
};
const [rootStat] = await this.workspaceService.roots;
const destinationFolderUri = await this.fileDialogService.showOpenDialog(props, rootStat);
if (destinationFolderUri) {
if (destinationFolderUri &&
this.getCurrentWorkspaceUri().toString() !== destinationFolderUri.toString()) {
const destinationFolder = await this.fileSystem.getFileStat(destinationFolderUri.toString());
if (destinationFolder && destinationFolder.isDirectory) {
this.workspaceService.open(destinationFolderUri);
Expand Down Expand Up @@ -274,7 +275,8 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi
const props = await this.openWorkspaceOpenFileDialogProps();
const [rootStat] = await this.workspaceService.roots;
const workspaceFolderOrWorkspaceFileUri = await this.fileDialogService.showOpenDialog(props, rootStat);
if (workspaceFolderOrWorkspaceFileUri) {
if (workspaceFolderOrWorkspaceFileUri &&
this.getCurrentWorkspaceUri().toString() !== workspaceFolderOrWorkspaceFileUri.toString()) {
const destinationFolder = await this.fileSystem.getFileStat(workspaceFolderOrWorkspaceFileUri.toString());
if (destinationFolder) {
this.workspaceService.open(workspaceFolderOrWorkspaceFileUri);
Expand Down Expand Up @@ -383,6 +385,15 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi
return environment.electron.is();
}

/**
* Get the current workspace URI.
*
* @returns the current workspace URI.
*/
private getCurrentWorkspaceUri(): URI {
return new URI(this.workspaceService.workspace && this.workspaceService.workspace.uri);
}

}

export namespace WorkspaceFrontendContribution {
Expand Down