mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Use MemoryExtensions.IndexOfAny in PSv2CompletionCompleter` (#18245)
This commit is contained in:
@@ -691,8 +691,9 @@ namespace System.Management.Automation
|
||||
/// </remarks>
|
||||
private static class PSv2CompletionCompleter
|
||||
{
|
||||
private const string CharsRequiringQuotedString = "`&@'#{}()$,;|<> \t";
|
||||
|
||||
private static readonly Regex s_cmdletTabRegex = new Regex(@"^[\w\*\?]+-[\w\*\?]*");
|
||||
private static readonly char[] s_charsRequiringQuotedString = "`&@'#{}()$,;|<> \t".ToCharArray();
|
||||
|
||||
#region "Handle Command"
|
||||
|
||||
@@ -939,7 +940,7 @@ namespace System.Management.Automation
|
||||
|
||||
private static string AddQuoteIfNecessary(string completionText, string quote, bool completingAtStartOfLine)
|
||||
{
|
||||
if (completionText.IndexOfAny(s_charsRequiringQuotedString) != -1)
|
||||
if (completionText.AsSpan().IndexOfAny(CharsRequiringQuotedString) >= 0)
|
||||
{
|
||||
bool needAmpersand = quote.Length == 0 && completingAtStartOfLine;
|
||||
string quoteInUse = quote.Length == 0 ? "'" : quote;
|
||||
|
||||
Reference in New Issue
Block a user