Skip to content

Commit ea91b93

Browse files
author
Kapil Borle
committed
Only analyze the function which requires comment help
1 parent 672fc9c commit ea91b93

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,22 +1091,23 @@ protected async Task HandleCommentHelpRequest(
10911091
{
10921092
// todo create a semantic marker api that take only string
10931093
var analysisResults = await EditorSession.AnalysisService.GetSemanticMarkersAsync(
1094-
scriptFile,
1094+
functionDefinitionAst.Extent.Text,
10951095
AnalysisService.GetCommentHelpRuleSettings(
10961096
true,
10971097
false,
10981098
requestParams.BlockComment,
10991099
true,
11001100
"before"));
11011101

1102-
var analysisResult = analysisResults?.FirstOrDefault(x =>
1103-
{
1104-
return x.Correction != null
1105-
&& x.Correction.Edits[0].StartLineNumber == expectedFunctionLine;
1106-
});
1107-
11081102
// find the analysis result whose correction starts on
1109-
result.Content = analysisResult?.Correction.Edits[0].Text.Split('\n').Select(x => x.Trim('\r')).ToArray();
1103+
result.Content = analysisResults?
1104+
.FirstOrDefault()?
1105+
.Correction?
1106+
.Edits[0]
1107+
.Text
1108+
.Split('\n')
1109+
.Select(x => x.Trim('\r'))
1110+
.ToArray();
11101111
}
11111112

11121113
await requestContext.SendResult(result);

0 commit comments

Comments
 (0)