Skip to content

Commit

Permalink
Do not re-open an already currently opened workspace
Browse files Browse the repository at this point in the history
Fixes #5630

- fixes an issue that allows users to open a workspace
that is currently opened. If the user had the preference
`"workspace.preserveWindow"` set to `false` it would open
an identical workspace in a new tab, and if it was set to
`true` it would reload the workspace. Instead, an additional
check is performed to determine if the current workspace and
the new destination are equal, and if they are a NOOP is
instead performed by returning `undefined`.

Signed-off-by: Vincent Fugnitto <[email protected]>
  • Loading branch information
vince-fugnitto committed Jul 3, 2019
1 parent 20d60b3 commit ea03237
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
ConfirmDialog, KeybindingRegistry, KeybindingContribution, CommonCommands
} from '@theia/core/lib/browser';
import { FileDialogService, OpenFileDialogProps, FileDialogTreeFilters } from '@theia/filesystem/lib/browser';
import { FileSystem } from '@theia/filesystem/lib/common';
import { FileSystem, FileStat } from '@theia/filesystem/lib/common';
import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
import { WorkspaceService } from './workspace-service';
import { THEIA_EXT, VSCODE_EXT } from '../common';
Expand Down Expand Up @@ -181,6 +181,10 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi
}, rootStat);
if (destinationUri) {
const destination = await this.fileSystem.getFileStat(destinationUri.toString());
// If the current workspace and destination are equal, do nothing.
if (FileStat.equals(destination, this.workspaceService.workspace)) {
return undefined;
}
if (destination) {
if (destination.isDirectory) {
this.workspaceService.open(destinationUri);
Expand Down

0 comments on commit ea03237

Please sign in to comment.