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()
246246 return ruleNames ;
247247 }
248248
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>
249254 public async Task < string > Format ( string scriptDefinition )
250255 {
251- var result = InvokePowerShellAsync (
256+ if ( ! hasScriptAnalyzerModule )
257+ {
258+ return null ;
259+ }
260+
261+ var result = await InvokePowerShellAsync (
252262 "Invoke-Formatter" ,
253263 new Dictionary < string , object > {
254264 { "ScriptDefinition" , scriptDefinition }
255265 } ) ;
256266
257- return ( await result ) ? . Select ( r => r . ImmediateBaseObject as string ) . FirstOrDefault ( ) ;
267+ return result ? . Select ( r => r . ImmediateBaseObject as string ) . FirstOrDefault ( ) ;
258268 }
259269
260270 /// <summary>
You can’t perform that action at this time.
0 commit comments