Skip to content

Commit c1e6b41

Browse files
authored
Use MemoryExtensions.IndexOfAny in PSv2CompletionCompleter` (PowerShell#18245)
1 parent 3e15fc5 commit c1e6b41

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/System.Management.Automation/engine/CommandCompletion/CommandCompletion.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,9 @@ private static List<CompletionResult> InvokeLegacyTabExpansion(PowerShell powers
691691
/// </remarks>
692692
private static class PSv2CompletionCompleter
693693
{
694+
private const string CharsRequiringQuotedString = "`&@'#{}()$,;|<> \t";
695+
694696
private static readonly Regex s_cmdletTabRegex = new Regex(@"^[\w\*\?]+-[\w\*\?]*");
695-
private static readonly char[] s_charsRequiringQuotedString = "`&@'#{}()$,;|<> \t".ToCharArray();
696697

697698
#region "Handle Command"
698699

@@ -939,7 +940,7 @@ internal static List<CompletionResult> PSv2GenerateMatchSetOfFiles(PowerShellExe
939940

940941
private static string AddQuoteIfNecessary(string completionText, string quote, bool completingAtStartOfLine)
941942
{
942-
if (completionText.IndexOfAny(s_charsRequiringQuotedString) != -1)
943+
if (completionText.AsSpan().IndexOfAny(CharsRequiringQuotedString) >= 0)
943944
{
944945
bool needAmpersand = quote.Length == 0 && completingAtStartOfLine;
945946
string quoteInUse = quote.Length == 0 ? "'" : quote;

0 commit comments

Comments
 (0)