mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 20:56:02 +00:00
Use MemoryExtensions.IndexOfAny in PSv2CompletionCompleter` (#18245)
This commit is contained in:
1 parent
3e15fc5128
commit
c1e6b41f98
1 file changed
+3
-2
@@ -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