@@ -67,6 +67,10 @@ protected override void Initialize()
6767
6868 this . SetRequestHandler ( ShowOnlineHelpRequest . Type , this . HandleShowOnlineHelpRequest ) ;
6969 this . SetRequestHandler ( ExpandAliasRequest . Type , this . HandleExpandAliasRequest ) ;
70+
71+ this . SetRequestHandler ( FindModuleRequest . Type , this . HandleFindModuleRequest ) ;
72+ this . SetRequestHandler ( InstallModuleRequest . Type , this . HandleInstallModuleRequest ) ;
73+
7074 this . SetEventHandler ( CompleteChoicePromptNotification . Type , this . HandleCompleteChoicePromptNotification ) ;
7175
7276 this . SetRequestHandler ( DebugAdapterMessages . EvaluateRequest . Type , this . HandleEvaluateRequest ) ;
@@ -128,12 +132,28 @@ protected async Task HandleShowOnlineHelpRequest(
128132 psCommand . AddArgument ( helpParams ) ;
129133 psCommand . AddParameter ( "Online" ) ;
130134
131- await editorSession . PowerShellContext . ExecuteCommand < object > (
132- psCommand ) ;
135+ await editorSession . PowerShellContext . ExecuteCommand < object > ( psCommand ) ;
136+
137+ await requestContext . SendResult ( null ) ;
138+ }
139+
140+ private async Task HandleInstallModuleRequest (
141+ string moduleName ,
142+ RequestContext < object > requestContext
143+ )
144+ {
145+ var script = string . Format ( "Install-Module -Name {0} -Scope CurrentUser" , moduleName ) ;
146+
147+ var executeTask =
148+ editorSession . PowerShellContext . ExecuteScriptString (
149+ script ,
150+ true ,
151+ true ) . ConfigureAwait ( false ) ;
133152
134153 await requestContext . SendResult ( null ) ;
135154 }
136155
156+
137157 private async Task HandleExpandAliasRequest (
138158 string content ,
139159 RequestContext < string > requestContext )
@@ -172,6 +192,28 @@ Sort Start -Descending
172192 await requestContext . SendResult ( result . First ( ) . ToString ( ) ) ;
173193 }
174194
195+ private async Task HandleFindModuleRequest (
196+ object param ,
197+ RequestContext < object > requestContext )
198+ {
199+ var psCommand = new PSCommand ( ) ;
200+ psCommand . AddScript ( "Find-Module | Select Name, Description" ) ;
201+
202+ var modules = await editorSession . PowerShellContext . ExecuteCommand < PSObject > ( psCommand ) ;
203+
204+ var moduleList = new List < PSModuleMessage > ( ) ;
205+
206+ if ( modules != null )
207+ {
208+ foreach ( dynamic m in modules )
209+ {
210+ moduleList . Add ( new PSModuleMessage { Name = m . Name , Description = m . Description } ) ;
211+ }
212+ }
213+
214+ await requestContext . SendResult ( moduleList ) ;
215+ }
216+
175217 protected Task HandleCompleteChoicePromptNotification (
176218 CompleteChoicePromptNotification completeChoicePromptParams ,
177219 EventContext eventContext )
0 commit comments