From ab3b9b8257c56bcb2fede02c3d8db801d6705311 Mon Sep 17 00:00:00 2001 From: Muhammad Anas Shahid Date: Mon, 9 Mar 2020 13:24:38 -0400 Subject: [PATCH] Cannot create a new file if the preferences widget is opened. Fixes: https://github.com/eclipse-theia/theia/issues/7067 , https://github.com/eclipse-theia/theia/issues/7253 Initially we were unable to create a new file or folder while the user preferences was open. The user-preferences has the file scheme set as `user-storage` and we did not fall back to the workspace root URI and instead were getting the URI from 'user_storage:settings.json'. With this approach, we create files at certain directories and if a directory doesn't have the scheme set to 'file' it will fallback to the workspace root uri. Signed-off-by: Muhammad Anas Shahid --- packages/workspace/src/browser/workspace-commands.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/workspace/src/browser/workspace-commands.ts b/packages/workspace/src/browser/workspace-commands.ts index b9a79f747ce36..a81ff7fb66a42 100644 --- a/packages/workspace/src/browser/workspace-commands.ts +++ b/packages/workspace/src/browser/workspace-commands.ts @@ -464,8 +464,8 @@ export class WorkspaceRootUriAwareCommandHandler extends UriAwareCommandHandler< // eslint-disable-next-line @typescript-eslint/no-explicit-any protected getUri(...args: any[]): URI | undefined { const uri = super.getUri(...args); - // If the URI is available, return it immediately. - if (uri) { + // Return the `uri` immediately if the resource exists in any of the workspace roots and is of `file` scheme. + if (uri && uri.scheme === 'file' && this.workspaceService.getWorkspaceRootUri(uri)) { return uri; } // Return the first root if available.