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

Code before:
                PSModuleInfo curModule = context.ExecutionContext.EngineSessionState.Module;
                if (loadedModulesOnly && curModule?.NestedModules.Count > 0)
                {
                    nestedModulesToFilterOut = new(curModule.NestedModules);
                }

                foreach (PSObject item in psObjects)
                {
                    var moduleInfo = (PSModuleInfo)item.BaseObject;
                    var completionText = moduleInfo.Name;
                    var listItemText = completionText;
                    if (shortNameSearch
                        && completionText.Contains('.')
                        && !shortNamePattern.IsMatch(completionText.Substring(completionText.LastIndexOf('.') + 1))
                        && !shortNamePattern.IsMatch(completionText))
                    {
                        // This check is to make sure we don't return a module whose name only matches the user specified word in the middle.
                        // For example, when user completes with 'gmo power', we should not return 'Microsoft.PowerShell.Utility'.
                        continue;
                    }

                    if (nestedModulesToFilterOut is not null
                        && nestedModulesToFilterOut.Contains(moduleInfo))
                    {
                        continue;
                    }

                    var toolTip = "Description: " + moduleInfo.Description + "\r\nModuleType: "
                                  + moduleInfo.ModuleType.ToString() + "\r\nPath: "
                                  + moduleInfo.Path;

                    if (CompletionRequiresQuotes(completionText, false))
                    {
                        var quoteInUse = quote == string.Empty ? "'" : quote;
                        if (quoteInUse == "'")
                            completionText = completionText.Replace("'", "''");
                        completionText = quoteInUse + completionText + quoteInUse;
                    }
                    else
                    {
                        completionText = quote + completionText + quote;
                    }

                    result.Add(new CompletionResult(completionText, listItemText, CompletionResultType.ParameterValue, toolTip));
                }
            }

            return result;
        }

        #endregion Module Names

Review comment (suggestion):
```suggestion
                    if (nestedModulesToFilterOut?.Contains(moduleInfo))
```

Code after:
                // Note that, it's intentional to not hard code the name 'PSReadLine' in the change, so that in case the tab completion
                // is triggered from within a different module, its nested modules can also be filtered out.
                HashSet<PSModuleInfo> nestedModulesToFilterOut = null;
                PSModuleInfo currentModule = context.ExecutionContext.EngineSessionState.Module;
                if (loadedModulesOnly && currentModule?.NestedModules.Count > 0)
                {
                    nestedModulesToFilterOut = new(currentModule.NestedModules);
                }

                foreach (PSObject item in psObjects)
                {
                    var moduleInfo = (PSModuleInfo)item.BaseObject;
                    var completionText = moduleInfo.Name;
                    var listItemText = completionText;
                    if (shortNameSearch
                        && completionText.Contains('.')
                        && !shortNamePattern.IsMatch(completionText.Substring(completionText.LastIndexOf('.') + 1))
                        && !shortNamePattern.IsMatch(completionText))
                    {
                        // This check is to make sure we don't return a module whose name only matches the user specified word in the middle.
                        // For example, when user completes with 'gmo power', we should not return 'Microsoft.PowerShell.Utility'.
                        continue;
                    }

                    if (nestedModulesToFilterOut is not null
                        && nestedModulesToFilterOut.Contains(moduleInfo))
                    {
                        continue;
                    }

                    var toolTip = "Description: " + moduleInfo.Description + "\r\nModuleType: "
                                  + moduleInfo.ModuleType.ToString() + "\r\nPath: "
                                  + moduleInfo.Path;

                    if (CompletionRequiresQuotes(completionText, false))
                    {
                        var quoteInUse = quote == string.Empty ? "'" : quote;
                        if (quoteInUse == "'")
                            completionText = completionText.Replace("'", "''");
                        completionText = quoteInUse + completionText + quoteInUse;
                    }
                    else
                    {
                        completionText = quote + completionText + quote;
                    }

                    result.Add(new CompletionResult(completionText, listItemText, CompletionResultType.ParameterValue, toolTip));
                }
            }

            return result;