diff --git a/src/PowerShellEditorServices/Analysis/AnalysisService.cs b/src/PowerShellEditorServices/Analysis/AnalysisService.cs index f2dfa834e..67bec2aa4 100644 --- a/src/PowerShellEditorServices/Analysis/AnalysisService.cs +++ b/src/PowerShellEditorServices/Analysis/AnalysisService.cs @@ -263,8 +263,9 @@ public async Task Format( Hashtable settings, int[] rangeList) { - // we cannot use Range type therefore this workaround of using -1 default value - if (!_hasScriptAnalyzerModule) + // We cannot use Range type therefore this workaround of using -1 default value. + // Invoke-Formatter throws a ParameterBinderValidationException if the ScriptDefinition is an empty string. + if (!_hasScriptAnalyzerModule || string.IsNullOrEmpty(scriptDefinition)) { return null; }