From 2df4b987ce8cce3b6dc806a895305e0aeae7762e Mon Sep 17 00:00:00 2001 From: Ben Constable Date: Mon, 16 Aug 2021 14:19:22 +0100 Subject: [PATCH] Check return is not null and if so get directory info (#12763) --- .../WorkspacesHelper/VSCodeWorkspacesApi.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspacesApi.cs b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspacesApi.cs index 1f2e38bb11..b426f19d36 100644 --- a/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspacesApi.cs +++ b/src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.VSCodeWorkspaces/WorkspacesHelper/VSCodeWorkspacesApi.cs @@ -27,6 +27,14 @@ namespace Community.PowerToys.Run.Plugin.VSCodeWorkspaces.WorkspacesHelper if (typeWorkspace.TypeWorkspace.HasValue) { var folderName = Path.GetFileName(unescapeUri); + + // Check we haven't returned '' if we have a path like C:\ + if (string.IsNullOrEmpty(folderName)) + { + DirectoryInfo dirInfo = new DirectoryInfo(unescapeUri); + folderName = dirInfo.Name.TrimEnd(':'); + } + return new VSCodeWorkspace() { Path = uri,