|
15 | 15 | #include <hyprutils/string/String.hpp> |
16 | 16 | #include <hyprutils/os/Process.hpp> |
17 | 17 | #include <hyprutils/string/ConstVarList.hpp> |
| 18 | +#include <hyprutils/string/VarList2.hpp> |
18 | 19 |
|
19 | 20 | using namespace Hyprutils::String; |
20 | 21 | using namespace Hyprutils::OS; |
@@ -60,7 +61,7 @@ class CDesktopEntry : public IFinderResult { |
60 | 61 | const std::string_view TERMINAL_EXEC = *PTERMINALEXEC; |
61 | 62 |
|
62 | 63 | auto toExec = std::format("{}{}{}", LAUNCH_PREFIX.empty() ? std::string{""} : std::string{LAUNCH_PREFIX} + std::string{" "}, |
63 | | - m_terminal && !TERMINAL_EXEC.empty() ? std::string{TERMINAL_EXEC} + std::string{" "} : std::string{""}, m_exec); |
| 64 | + m_terminal && !TERMINAL_EXEC.empty() ? std::string{TERMINAL_EXEC} + std::string{" "} : std::string{""}, m_exec); |
64 | 65 |
|
65 | 66 | Debug::log(TRACE, "Running {}", toExec); |
66 | 67 |
|
@@ -265,10 +266,25 @@ void CDesktopFinder::cacheEntry(const std::filesystem::path& path) { |
265 | 266 | e->m_exec = EXEC; |
266 | 267 | e->m_icon = ICON; |
267 | 268 | e->m_name = NAME; |
268 | | - e->m_fuzzables = Fuzzy::createFuzzableStrings({NAME, GEN_NAME}); |
269 | 269 | e->m_stem = std::move(pathStem); |
270 | 270 | e->m_terminal = TERMINAL; |
271 | 271 | e->m_frequency = m_entryFrequencyCache->getCachedEntry(e->m_name); |
| 272 | + |
| 273 | + // create fuzzable strings. Read: name, generic name, but also keywords. |
| 274 | + std::vector<std::string_view> strings = {NAME, GEN_NAME}; |
| 275 | + const std::string_view KEYWORDS = extract("Keywords"); |
| 276 | + if (!KEYWORDS.empty()) { |
| 277 | + CVarList2 keywords(KEYWORDS, 0, ';', true); |
| 278 | + for (const auto& k : keywords) { |
| 279 | + strings.emplace_back(k); |
| 280 | + } |
| 281 | + |
| 282 | + // we need to emplace here because CVarList2 will be destroyed and the string_view |
| 283 | + // refs will become uafs |
| 284 | + e->m_fuzzables = Fuzzy::createFuzzableStrings(std::move(strings)); |
| 285 | + } else |
| 286 | + e->m_fuzzables = Fuzzy::createFuzzableStrings(std::move(strings)); |
| 287 | + |
272 | 288 | m_desktopEntryCacheGeneric.emplace_back(e); |
273 | 289 |
|
274 | 290 | Debug::log(TRACE, "desktop: cached {} with icon {} and exec line of \"{}\"", NAME, ICON, EXEC); |
|
0 commit comments