File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
src/PowerShellEditorServices/Analysis Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -246,15 +246,25 @@ public IEnumerable<string> GetPSScriptAnalyzerRules()
246
246
return ruleNames ;
247
247
}
248
248
249
+ /// <summary>
250
+ /// Format a given script text with default codeformatting settings.
251
+ /// </summary>
252
+ /// <param name="scriptDefinition">Script text to be formatted</param>
253
+ /// <returns>The formatted script text.</returns>
249
254
public async Task < string > Format ( string scriptDefinition )
250
255
{
251
- var result = InvokePowerShellAsync (
256
+ if ( ! hasScriptAnalyzerModule )
257
+ {
258
+ return null ;
259
+ }
260
+
261
+ var result = await InvokePowerShellAsync (
252
262
"Invoke-Formatter" ,
253
263
new Dictionary < string , object > {
254
264
{ "ScriptDefinition" , scriptDefinition }
255
265
} ) ;
256
266
257
- return ( await result ) ? . Select ( r => r . ImmediateBaseObject as string ) . FirstOrDefault ( ) ;
267
+ return result ? . Select ( r => r . ImmediateBaseObject as string ) . FirstOrDefault ( ) ;
258
268
}
259
269
260
270
/// <summary>
You can’t perform that action at this time.
0 commit comments