Repository: PowerShell/PowerShell
File: src/System.Management.Automation/engine/CommandCompletion/CompletionHelpers.cs (C#)

Code before:

        /// <summary>
        /// Checks if the given value matches the specified word or pattern.
        /// </summary>
        /// <param name="value">The input string to evaluate.</param>
        /// <param name="wordToComplete">The word or pattern to compare against.</param>
        /// <returns>
        /// <c>true</c> if the value matches the normalized word (case-insensitively) or the wildcard pattern; otherwise, <c>false</c>.
        /// </returns>
        /// <remarks>
        /// This method normalizes word to complete by replacing its line endings with backticks 
        /// and unescaping special characters. 
        /// It first does a a case-insensitive literal prefix match.
        /// If the literal match fails, the input value is then evaluated against this case-insensitive wildcard pattern.
        /// To prevent any exceptions when constructing wildcard pattern with existing wildcard characters,
        /// the word to complete is normalized by escaping wildcard characters first.
        /// </remarks>
        internal static bool IsMatch(string value, string wordToComplete)
        {
            string normalizedWord = WildcardPattern.Unescape(wordToComplete.ReplaceLineEndings("`"));

            bool match = value.StartsWith(normalizedWord, StringComparison.OrdinalIgnoreCase);

            if (!match)
            {
                normalizedWord = WildcardPattern.Escape(wordToComplete);

                match = WildcardPattern
                    .Get(normalizedWord + "*", WildcardOptions.IgnoreCase)
                    .IsMatch(value);
            }

            return match;
        }

        /// <summary>
        /// Removes wrapping quotes from a string and returns the quote used, if present.
        /// </summary>
        /// <param name="wordToComplete">
        /// The string to process, potentially surrounded by single or double quotes.
        /// This parameter is updated in-place to exclude the removed quotes.
        /// </param>
        /// <returns>
        /// The type of quote detected (single or double), or an empty string if no quote is found.
        /// </returns>
        /// <remarks>
        /// This method checks for single or double quotes at the start and end of the string.
        /// If wrapping quotes are detected and match, both are removed; otherwise, only the front quote is removed.
        /// The string is updated in-place, and only matching front-and-back quotes are stripped.
        /// If no quotes are detected or the input is empty, the original string remains unchanged.
        /// </remarks>

Review comment (suggestion):
Oh, this can already be considered a breaking change - the original code handled wildcard characters, now we are blocking this for all completers.
It might be worth making IsMatch a delegate already - default one without escaping.

Code after:
            {
                if (matchStrategy(value, wordToComplete))
                {
                    string completionText = QuoteCompletionText(value, quote);
                    string toolTip = toolTipMapping?.Invoke(value) ?? value;
                    string listItemText = listItemTextMapping?.Invoke(value) ?? value;

                    yield return new CompletionResult(completionText, listItemText, resultType, toolTip);
                }
            }
        }

        /// <summary>
        /// Normalizes the input string to an expandable string format for PowerShell.
        /// </summary>
        /// <param name="value">The input string to be normalized.</param>
        /// <returns>The normalized string with special characters replaced by their PowerShell escape sequences.</returns>
        /// <remarks>
        /// This method replaces special characters in the input string with their PowerShell equivalent escape sequences:
        /// <list type="bullet">
        ///     <item><description>Replaces "\r" (carriage return) with "`r".</description></item>
        ///     <item><description>Replaces "\n" (newline) with "`n".</description></item>
        ///     <item><description>Replaces "\t" (tab) with "`t".</description></item>
        ///     <item><description>Replaces "\0" (null) with "`0".</description></item>
        ///     <item><description>Replaces "\a" (bell) with "`a".</description></item>
        ///     <item><description>Replaces "\b" (backspace) with "`b".</description></item>
        ///     <item><description>Replaces "\u001b" (escape character) with "`e".</description></item>
        ///     <item><description>Replaces "\f" (form feed) with "`f".</description></item>
        ///     <item><description>Replaces "\v" (vertical tab) with "`v".</description></item>
        /// </list>
        /// </remarks>
        internal static string NormalizeToExpandableString(string value)
            => value
                .Replace("\r", "`r")
                .Replace("\n", "`n")
                .Replace("\t", "`t")
                .Replace("\0", "`0")
                .Replace("\a", "`a")
                .Replace("\b", "`b")
                .Replace("\u001b", "`e")
                .Replace("\f", "`f")
                .Replace("\v", "`v");

        /// <summary>
        /// Defines a strategy for determining if a value matches a word or pattern.
        /// </summary>
        /// <param name="value">The input string to check for a match.</param>
        /// <param name="wordToComplete">The word or pattern to match against.</param>
        /// <returns>
        /// <c>true</c> if the value matches the specified word or pattern; otherwise, <c>false</c>.
        /// </returns>