Skip to content

Commit 874a785

Browse files
authored
cache keywordIndex
1 parent 7a0be2c commit 874a785

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,21 @@ public List<Result> Query(Query query)
2626
LoadThemes();
2727
}
2828

29-
string search = query.Search[(query.Search.IndexOf(Keyword, StringComparison.Ordinal) + Keyword.Length + 1)..];
29+
int keywordIndex = query.Search.IndexOf(Keyword, StringComparison.Ordinal);
30+
string search = query.Search[(keywordIndex + Keyword.Length + 1)..];
3031

3132
if (string.IsNullOrWhiteSpace(search))
3233
{
3334
return themes.Select(CreateThemeResult)
34-
.OrderBy(x => x.Title)
35-
.ToList();
35+
.OrderBy(x => x.Title)
36+
.ToList();
3637
}
3738

3839
return themes.Select(theme => (theme, matchResult: context.API.FuzzySearch(search, theme)))
39-
.Where(x => x.matchResult.IsSearchPrecisionScoreMet())
40-
.Select(x => CreateThemeResult(x.theme, x.matchResult.Score, x.matchResult.MatchData))
41-
.OrderBy(x => x.Title)
42-
.ToList();
40+
.Where(x => x.matchResult.IsSearchPrecisionScoreMet())
41+
.Select(x => CreateThemeResult(x.theme, x.matchResult.Score, x.matchResult.MatchData))
42+
.OrderBy(x => x.Title)
43+
.ToList();
4344
}
4445

4546
private void OnVisibilityChanged(object sender, VisibilityChangedEventArgs args)

0 commit comments

Comments
 (0)