Switch to StartsWith using StringComparison.Ordinal

This commit is contained in:
Jeremy Sinclair 2023-08-23 20:00:46 -04:00
parent 5d1c3e6d2d
commit 71677a15d8

View File

@ -1075,7 +1075,7 @@ namespace PowerLauncher.ViewModel
else
{
// Using Ordinal this is internal
return string.IsNullOrEmpty(queryText) || autoCompleteText.IndexOf(queryText, StringComparison.Ordinal) != 0;
return string.IsNullOrEmpty(queryText) || !autoCompleteText.StartsWith(queryText, StringComparison.Ordinal);
}
}
@ -1086,7 +1086,7 @@ namespace PowerLauncher.ViewModel
if (index == 0)
{
// Using OrdinalIgnoreCase because we want the characters to be exact in autocomplete text and the query
if (input.IndexOf(query, StringComparison.OrdinalIgnoreCase) == 0)
if (input.StartsWith(query, StringComparison.OrdinalIgnoreCase))
{
// Use the same case as the input query for the matched portion of the string
return string.Concat(query, input.AsSpan(query.Length));
@ -1104,7 +1104,7 @@ namespace PowerLauncher.ViewModel
if (index == 0 && !string.IsNullOrEmpty(query))
{
// Using OrdinalIgnoreCase since this is internal
if (input.IndexOf(query, StringComparison.OrdinalIgnoreCase) == 0)
if (input.StartsWith(query, StringComparison.OrdinalIgnoreCase))
{
return string.Concat(query, input.AsSpan(query.Length));
}