From 1b31e96b10996f1db4b2cc01f1b3d13108d8e227 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Mon, 25 Jun 2018 17:24:08 -0700 Subject: [PATCH 1/2] fix tab exapnsion for get-process on macOS --- .../engine/CommandCompletion/CompletionCompleters.cs | 5 +++++ .../powershell/Host/TabCompletion/TabCompletion.Tests.ps1 | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs index 2fa8fbc68da..be94e066a49 100644 --- a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs +++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs @@ -3172,6 +3172,11 @@ private static void NativeCompletionProcessCommands(CompletionContext context, s completionText = quote + completionText + quote; } + if (string.IsNullOrEmpty(listItemText)) + { + continue; + } + result.Add(new CompletionResult(completionText, listItemText, CompletionResultType.ParameterValue, listItemText)); } diff --git a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 index 1be3ae286f8..505b11d87eb 100644 --- a/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 +++ b/test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1 @@ -115,6 +115,14 @@ Describe "TabCompletion" -Tags CI { $res.CompletionMatches[0].ToolTip -match '^\d+ -' | Should -BeTrue } + It 'Should complete "Get-Process" with process names' { + $cmd = "Get-Process " + $res = TabExpansion2 -inputScript $cmd -cursorColumn $cmd.Length + # Can't compare to number of processes since macOS has a large number of processes + # that have empty Name which should be skipped + $res.CompletionMatches.Count | Should -BeGreaterThan 0 + } + It 'Should complete keyword' -skip { $res = TabExpansion2 -inputScript 'using nam' -cursorColumn 'using nam'.Length $res.CompletionMatches[0].CompletionText | Should -Be 'namespace' From 399f3a335afb9519a7b5dafb301c3ec8ac6b7257 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 26 Jun 2018 13:52:05 -0700 Subject: [PATCH 2/2] add comment to address PR feedback --- .../engine/CommandCompletion/CompletionCompleters.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs index be94e066a49..cf88b76bca7 100644 --- a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs +++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs @@ -3172,6 +3172,7 @@ private static void NativeCompletionProcessCommands(CompletionContext context, s completionText = quote + completionText + quote; } + // on macOS, system processes names will be empty if PowerShell isn't run as `sudo` if (string.IsNullOrEmpty(listItemText)) { continue;