Skip to content

Commit 04e551d

Browse files
committed
Replace TryGetValue
Signed-off-by: Florian Grabmeier <[email protected]>
1 parent b2b9f7c commit 04e551d

File tree

1 file changed

+10
-8
lines changed
  • Plugins/Flow.Launcher.Plugin.Sys

1 file changed

+10
-8
lines changed

Plugins/Flow.Launcher.Plugin.Sys/Main.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,23 @@ public List<Result> Query(Query query)
8484

8585
private string GetDynamicTitle(Query query, Result result)
8686
{
87-
var pair = KeywordTitleMappings
88-
.Where(kvp => kvp.Key == result.Title && kvp.Key != kvp.Value)
89-
.FirstOrDefault();
90-
91-
if (pair.Equals(default))
87+
if (!KeywordTitleMappings.TryGetValue(result.Title, out var translationKey))
9288
{
9389
Log.Error($"Dynamic Title not found for: {result.Title}");
9490
return "Title Not Found";
9591
}
9692

97-
var translatedTitle = context.API.GetTranslation(pair.Value);
98-
var englishTitleMatch = StringMatcher.FuzzySearch(query.Search, pair.Key);
93+
var translatedTitle = context.API.GetTranslation(translationKey);
94+
95+
if (result.Title == translatedTitle)
96+
{
97+
return result.Title;
98+
}
99+
100+
var englishTitleMatch = StringMatcher.FuzzySearch(query.Search, result.Title);
99101
var translatedTitleMatch = StringMatcher.FuzzySearch(query.Search, translatedTitle);
100102

101-
return englishTitleMatch.Score >= translatedTitleMatch.Score ? pair.Key : translatedTitle;
103+
return englishTitleMatch.Score >= translatedTitleMatch.Score ? result.Title : translatedTitle;
102104
}
103105

104106
public void Init(PluginInitContext context)

0 commit comments

Comments
 (0)