Skip to content

Commit c4e8866

Browse files
author
Kapil Borle
committed
Disable server side range formatting
1 parent d00e2ca commit c4e8866

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ await requestContext.SendResult(
200200
{
201201
TriggerCharacters = new string[] { " " } // TODO: Other characters here?
202202
},
203-
DocumentFormattingProvider = true,
204-
DocumentRangeFormattingProvider = true
203+
DocumentFormattingProvider = true
205204
}
206205
});
207206
}

src/PowerShellEditorServices/Analysis/AnalysisService.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,26 @@ public async Task<string> Format(
264264
return null;
265265
}
266266

267-
var result = await InvokePowerShellAsync(
268-
"Invoke-Formatter",
269-
new Dictionary<string, object> {
267+
Dictionary<string, object> argsDict;
268+
269+
// this is a workaround till range formatter is enable in script analyzer
270+
if (startLineNumber == -1)
271+
{
272+
argsDict = new Dictionary<string, object> {
273+
{"ScriptDefinition", scriptDefinition}
274+
};
275+
}
276+
else
277+
{
278+
argsDict = new Dictionary<string, object> {
270279
{"ScriptDefinition", scriptDefinition},
271280
{"StartLineNumber", startLineNumber},
272281
{"StartColumnNumber", startColumnNumber},
273282
{"EndLineNumber", endLineNumber},
274283
{"EndColumnNumber", endColumnNumber}
275-
});
276-
284+
};
285+
}
286+
var result = await InvokePowerShellAsync("Invoke-Formatter", argsDict);
277287
return result?.Select(r => r.ImmediateBaseObject as string).FirstOrDefault();
278288
}
279289

0 commit comments

Comments
 (0)