Repository: microsoft/PowerToys
File: src/modules/Workspaces/WorkspacesLib/AppUtils.cpp (C++)

Code before:
                        .name = std::filesystem::path(appPath).stem(),
                        .installPath = appPath,
                    };
                }
            }

            // search in apps list
            for (const auto& appData : apps)
            {
                if (!appData.installPath.empty())
                {
                    std::wstring installPathUpper(appData.installPath);
                    std::transform(installPathUpper.begin(), installPathUpper.end(), installPathUpper.begin(), towupper);

                    if (appPathUpper.contains(installPathUpper))
                    {
                        // check if the found app is the System Settings. If yes, update the install path to the exe path
                        if (appPathUpper.ends_with(NonLocalizable::SystemSettingsPath))
                        {
                            return AppData{
                                .name = NonLocalizable::SystemSettingsName,
                                .installPath = appPath,
                                .packageFullName = appData.packageFullName,
                                .appUserModelId = appData.appUserModelId,
                                .canLaunchElevated = appData.canLaunchElevated
                            };
                        }

                        return appData;
                    }

                    // edge case, some apps (e.g., Gitkraken) have different .exe files in the subfolders.
                    // apps list contains only one path, so in this case app is not found
                    if (std::filesystem::path(appPath).filename() == std::filesystem::path(appData.installPath).filename())
                    {
                        return appData;
                    }
                }
            }

            // try by name if path not found
            // apps list could contain a different path from that one we get from the process (for electron)
            std::wstring exeName = std::filesystem::path(appPath).stem();
            std::wstring exeNameUpper(exeName);
            std::transform(exeNameUpper.begin(), exeNameUpper.end(), exeNameUpper.begin(), towupper);

            for (const auto& appData : apps)
            {
                std::wstring appNameUpper(appData.name);
                std::transform(appNameUpper.begin(), appNameUpper.end(), appNameUpper.begin(), towupper);


Review comment (suggestion):
```suggestion
                            auto settingsAppData = appData;
                            settingsAppData.installPath = appPath;
                            return settingsAppData;
```

Code after:
                        .installPath = appPath,
                    };
                }
            }

            // search in apps list
            for (const auto& appData : apps)
            {
                if (!appData.installPath.empty())
                {
                    std::wstring installPathUpper(appData.installPath);
                    std::transform(installPathUpper.begin(), installPathUpper.end(), installPathUpper.begin(), towupper);

                    if (appPathUpper.contains(installPathUpper))
                    {
                        // check if the found app is the System Settings. If yes, update the install path to the exe path
                        if (appPathUpper.ends_with(NonLocalizable::SystemSettingsPath))
                        {
                            auto settingsAppData = appData;
                            settingsAppData.installPath = appPath;
                            return settingsAppData;
                        }

                        return appData;
                    }

                    // edge case, some apps (e.g., Gitkraken) have different .exe files in the subfolders.
                    // apps list contains only one path, so in this case app is not found
                    if (std::filesystem::path(appPath).filename() == std::filesystem::path(appData.installPath).filename())
                    {
                        return appData;
                    }
                }
            }

            // try by name if path not found
            // apps list could contain a different path from that one we get from the process (for electron)
            std::wstring exeName = std::filesystem::path(appPath).stem();
            std::wstring exeNameUpper(exeName);
            std::transform(exeNameUpper.begin(), exeNameUpper.end(), exeNameUpper.begin(), towupper);

            for (const auto& appData : apps)
            {
                std::wstring appNameUpper(appData.name);
                std::transform(appNameUpper.begin(), appNameUpper.end(), appNameUpper.begin(), towupper);

                if (appNameUpper == exeNameUpper)
                {
                    auto result = appData;
                    result.installPath = appPath;
                    return result;