Check return is not null and if so get directory info (#12763)

This commit is contained in:
Ben Constable 2021-08-16 14:19:22 +01:00 committed by GitHub
parent 7f7ab5f5b1
commit 2df4b987ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,