Skip to content

Commit 3e32ae5

Browse files
bbedwardoutfoxxed
authored andcommitted
core/desktopentry: don't match keys with wrong modifier or country
1 parent 2eacb71 commit 3e32ae5

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

changelog/next.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
- Fixed a rare crash when disconnecting a monitor.
1515
- Fixed build issues preventing cross compilation from working.
1616
- Fixed dekstop entries with lower priority than a hidden entry not being hidden.
17+
- Fixed desktop entry keys with mismatched modifier or country not being discarded.

src/core/desktopentry.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ struct Locale {
6161

6262
[[nodiscard]] int matchScore(const Locale& other) const {
6363
if (this->language != other.language) return 0;
64-
auto territoryMatches = !this->territory.isEmpty() && this->territory == other.territory;
65-
auto modifierMatches = !this->modifier.isEmpty() && this->modifier == other.modifier;
64+
65+
if (!other.modifier.isEmpty() && this->modifier != other.modifier) return 0;
66+
if (!other.territory.isEmpty() && this->territory != other.territory) return 0;
6667

6768
auto score = 1;
68-
if (territoryMatches) score += 2;
69-
if (modifierMatches) score += 1;
69+
70+
if (!other.territory.isEmpty()) score += 2;
71+
if (!other.modifier.isEmpty()) score += 1;
7072

7173
return score;
7274
}

0 commit comments

Comments
 (0)