Skip to content

Commit cda81cd

Browse files
committed
Eliminate AddScript (among other things)
1 parent 0a795d5 commit cda81cd

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/PowerShellEditorServices.Protocol/LanguageServer/GetCommandRequest.cs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer
1111
{
12-
1312
/// <summary>
1413
/// Describes the request to get the details for PowerShell Commands from the current session.
1514
/// </summary>

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -530,15 +530,21 @@ private async Task HandleGetCommandRequest(
530530
RequestContext<object> requestContext)
531531
{
532532
PSCommand psCommand = new PSCommand();
533-
if (param != "") {
533+
if (!string.IsNullOrEmpty(param)) {
534534
psCommand.AddCommand("Microsoft.PowerShell.Core\\Get-Command").AddArgument(param);
535535
}
536536
else
537537
{
538-
psCommand.AddScript("Microsoft.PowerShell.Core\\Get-Command -CommandType Function, Cmdlet, ExternalScript | Select-Object Name,ModuleName | Sort-Object Name");
538+
psCommand.AddCommand("Microsoft.PowerShell.Core\\Get-Command")
539+
.AddParameter("CommandType", new[]{"Function", "Cmdlet", "ExternalScript"})
540+
.AddCommand("Select-Object")
541+
.AddParameter("Property", new[]{"Name", "ModuleName"})
542+
.AddCommand("Sort-Object")
543+
.AddParameter("Property", "Name");
544+
// psCommand.AddScript("Microsoft.PowerShell.Core\\Get-Command -CommandType Function, Cmdlet, ExternalScript | Select-Object Name,ModuleName | Sort-Object Name");
539545
}
540546
IEnumerable<PSObject> result = await this.editorSession.PowerShellContext.ExecuteCommand<PSObject>(psCommand);
541-
List<PSCommandMessage> commandList = new List<PSCommandMessage>();
547+
var commandList = new List<PSCommandMessage>();
542548

543549
if (result != null)
544550
{

0 commit comments

Comments
 (0)