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

Code before:

        #endregion Filenames

        #region Variable

        /// <summary>
        /// </summary>
        /// <param name="variableName"></param>
        /// <returns></returns>
        public static IEnumerable<CompletionResult> CompleteVariable(string variableName)
        {
            var runspace = Runspace.DefaultRunspace;
            if (runspace == null)
            {
                // No runspace, just return no results.
                return CommandCompletion.EmptyCompletionResult;
            }

            var helper = new PowerShellExecutionHelper(PowerShell.Create(RunspaceMode.CurrentRunspace));
            var executionContext = helper.CurrentPowerShell.Runspace.ExecutionContext;
            return CompleteVariable(new CompletionContext { WordToComplete = variableName, Helper = helper, ExecutionContext = executionContext });
        }

        private static readonly string[] s_variableScopes = new string[] { "Global:", "Local:", "Script:", "Private:" };

        private static readonly SearchValues<char> s_charactersRequiringQuotes = SearchValues.Create("-`&@'\"#{}()$ ,;|<> .\\/ \t^");

        private static bool ContainsCharactersRequiringQuotes(ReadOnlySpan<char> text)
            => text.ContainsAny(s_charactersRequiringQuotes);

        internal static List<CompletionResult> CompleteVariable(CompletionContext context)
        {
            HashSet<string> hashedResults = new(StringComparer.OrdinalIgnoreCase);
            List<CompletionResult> results = new();
            List<CompletionResult> tempResults = new();

            var wordToComplete = context.WordToComplete;
            var colon = wordToComplete.IndexOf(':');

            var lastAst = context.RelatedAsts?[^1];
            var variableAst = lastAst as VariableExpressionAst;
            if (lastAst is PropertyMemberAst ||
                (lastAst is not null && lastAst.Parent is ParameterAst parameter && parameter.DefaultValue != lastAst))
            {
                // User is adding a new parameter or a class member, variable tab completion is not useful.
                return results;
            }
            var prefix = variableAst != null && variableAst.Splatted ? "@" : "$";
            bool tokenAtCursorUsedBraces = context.TokenAtCursor is not null && context.TokenAtCursor.Text.StartsWith("${");

            // Look for variables in the input (e.g. parameters, etc.) before checking session state - these

Review comment (suggestion):
One extra space:
```suggestion
        private static readonly SearchValues<char> s_charactersRequiringQuotes = SearchValues.Create("-`&@'\"#{}()$,;|<> .\\/ \t^");
```

Code after:

        #endregion Filenames

        #region Variable

        /// <summary>
        /// </summary>
        /// <param name="variableName"></param>
        /// <returns></returns>
        public static IEnumerable<CompletionResult> CompleteVariable(string variableName)
        {
            var runspace = Runspace.DefaultRunspace;
            if (runspace == null)
            {
                // No runspace, just return no results.
                return CommandCompletion.EmptyCompletionResult;
            }

            var helper = new PowerShellExecutionHelper(PowerShell.Create(RunspaceMode.CurrentRunspace));
            var executionContext = helper.CurrentPowerShell.Runspace.ExecutionContext;
            return CompleteVariable(new CompletionContext { WordToComplete = variableName, Helper = helper, ExecutionContext = executionContext });
        }

        private static readonly string[] s_variableScopes = new string[] { "Global:", "Local:", "Script:", "Private:" };

        private static readonly SearchValues<char> s_charactersRequiringQuotes = SearchValues.Create("-`&@'\"#{}()$,;|<> .\\/ \t^");

        private static bool ContainsCharactersRequiringQuotes(ReadOnlySpan<char> text)
            => text.ContainsAny(s_charactersRequiringQuotes);

        internal static List<CompletionResult> CompleteVariable(CompletionContext context)
        {
            HashSet<string> hashedResults = new(StringComparer.OrdinalIgnoreCase);
            List<CompletionResult> results = new();
            List<CompletionResult> tempResults = new();

            var wordToComplete = context.WordToComplete;
            var colon = wordToComplete.IndexOf(':');

            var lastAst = context.RelatedAsts?[^1];
            var variableAst = lastAst as VariableExpressionAst;
            if (lastAst is PropertyMemberAst ||
                (lastAst is not null && lastAst.Parent is ParameterAst parameter && parameter.DefaultValue != lastAst))
            {
                // User is adding a new parameter or a class member, variable tab completion is not useful.
                return results;
            }
            var prefix = variableAst != null && variableAst.Splatted ? "@" : "$";
            bool tokenAtCursorUsedBraces = context.TokenAtCursor is not null && context.TokenAtCursor.Text.StartsWith("${");

            // Look for variables in the input (e.g. parameters, etc.) before checking session state - these