Skip to content

Commit c9ecea9

Browse files
Kapil Borledaviwil
Kapil Borle
authored andcommitted
Fix comment help completion when function not in context
1 parent a52a184 commit c9ecea9

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,10 +1085,7 @@ protected async Task HandleCommentHelpRequest(
10851085
var functionDefinitionAst = EditorSession.LanguageService.GetFunctionDefinitionAtLine(
10861086
scriptFile,
10871087
expectedFunctionLine);
1088-
var result = new CommentHelpRequestResult()
1089-
{
1090-
Content = new string[] { "" }
1091-
};
1088+
var result = new CommentHelpRequestResult();
10921089

10931090
if (functionDefinitionAst != null)
10941091
{
@@ -1098,6 +1095,7 @@ protected async Task HandleCommentHelpRequest(
10981095
ruleSettings.Add("Enable", true);
10991096
ruleSettings.Add("BlockComment", requestParams.BlockComment);
11001097
ruleSettings.Add("VSCodeSnippetCorrection", true);
1098+
ruleSettings.Add("Placement", "before");
11011099
settings.Add("PSProvideCommentHelp", ruleSettings);
11021100
var pssaSettings = EditorSession.AnalysisService.GetPSSASettingsHashtable(settings);
11031101

@@ -1112,11 +1110,8 @@ protected async Task HandleCommentHelpRequest(
11121110
&& x.Correction.Edits[0].StartLineNumber == expectedFunctionLine;
11131111
});
11141112

1115-
if (analysisResult != null)
1116-
{
1117-
// find the analysis result whose correction starts on
1118-
result.Content = analysisResult.Correction.Edits[0].Text.Split('\n').Select(x => x.Trim('\r')).ToArray();
1119-
}
1113+
// find the analysis result whose correction starts on
1114+
result.Content = analysisResult?.Correction.Edits[0].Text.Split('\n').Select(x => x.Trim('\r')).ToArray();
11201115
}
11211116

11221117
await requestContext.SendResult(result);

0 commit comments

Comments
 (0)