Skip to content

Commit 4d36356

Browse files
Merge pull request #1738 from PowerShell/andschwa/completions
Improve completion logic This makes the deduced `CompletionItemKind` enum more accurate, which results in better icons for the user when viewing completions in an editor. Also cleaned up the file as there were remnants of dead code. Fixes PowerShell/vscode-powershell#3364
2 parents 6e5bea7 + 912392e commit 4d36356

File tree

11 files changed

+432
-766
lines changed

11 files changed

+432
-766
lines changed

src/PowerShellEditorServices/Services/PowerShell/Utility/CommandHelpers.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ internal static class CommandHelpers
6464
public static async Task<CommandInfo> GetCommandInfoAsync(
6565
string commandName,
6666
IRunspaceInfo currentRunspace,
67-
IInternalPowerShellExecutionService executionService)
67+
IInternalPowerShellExecutionService executionService,
68+
CancellationToken cancellationToken = default)
6869
{
6970
// This mechanism only works in-process
7071
if (currentRunspace.RunspaceOrigin != RunspaceOrigin.Local)
@@ -98,7 +99,7 @@ public static async Task<CommandInfo> GetCommandInfoAsync(
9899
.AddParameter("ErrorAction", "Ignore");
99100

100101
IReadOnlyList<CommandInfo> results = await executionService
101-
.ExecutePSCommandAsync<CommandInfo>(command, CancellationToken.None)
102+
.ExecutePSCommandAsync<CommandInfo>(command, cancellationToken)
102103
.ConfigureAwait(false);
103104

104105
CommandInfo commandInfo = results.Count > 0 ? results[0] : null;
@@ -120,7 +121,8 @@ public static async Task<CommandInfo> GetCommandInfoAsync(
120121
/// <returns>The synopsis.</returns>
121122
public static async Task<string> GetCommandSynopsisAsync(
122123
CommandInfo commandInfo,
123-
IInternalPowerShellExecutionService executionService)
124+
IInternalPowerShellExecutionService executionService,
125+
CancellationToken cancellationToken = default)
124126
{
125127
Validate.IsNotNull(nameof(commandInfo), commandInfo);
126128
Validate.IsNotNull(nameof(executionService), executionService);
@@ -151,7 +153,7 @@ public static async Task<string> GetCommandSynopsisAsync(
151153
.AddParameter("ErrorAction", "Ignore");
152154

153155
IReadOnlyList<PSObject> results = await executionService
154-
.ExecutePSCommandAsync<PSObject>(command, CancellationToken.None)
156+
.ExecutePSCommandAsync<PSObject>(command, cancellationToken)
155157
.ConfigureAwait(false);
156158

157159
// Extract the synopsis string from the object

src/PowerShellEditorServices/Services/TextDocument/CompletionResults.cs

Lines changed: 0 additions & 339 deletions
This file was deleted.

0 commit comments

Comments
 (0)