From 3e32ae595f97bd2d2e5ed4512fb4bb25edb4eae6 Mon Sep 17 00:00:00 2001 From: bbedward Date: Tue, 30 Sep 2025 08:17:03 -0400 Subject: [PATCH] core/desktopentry: don't match keys with wrong modifier or country --- changelog/next.md | 1 + src/core/desktopentry.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/changelog/next.md b/changelog/next.md index 4e24c67..38f2f7a 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -14,3 +14,4 @@ - Fixed a rare crash when disconnecting a monitor. - Fixed build issues preventing cross compilation from working. - Fixed dekstop entries with lower priority than a hidden entry not being hidden. +- Fixed desktop entry keys with mismatched modifier or country not being discarded. diff --git a/src/core/desktopentry.cpp b/src/core/desktopentry.cpp index b453988..941a405 100644 --- a/src/core/desktopentry.cpp +++ b/src/core/desktopentry.cpp @@ -61,12 +61,14 @@ struct Locale { [[nodiscard]] int matchScore(const Locale& other) const { if (this->language != other.language) return 0; - auto territoryMatches = !this->territory.isEmpty() && this->territory == other.territory; - auto modifierMatches = !this->modifier.isEmpty() && this->modifier == other.modifier; + + if (!other.modifier.isEmpty() && this->modifier != other.modifier) return 0; + if (!other.territory.isEmpty() && this->territory != other.territory) return 0; auto score = 1; - if (territoryMatches) score += 2; - if (modifierMatches) score += 1; + + if (!other.territory.isEmpty()) score += 2; + if (!other.modifier.isEmpty()) score += 1; return score; }