Skip to content

Commit d26790e

Browse files
author
Kapil Borle
committed
Fix help completion within function defition body
1 parent e0c5dd7 commit d26790e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1082,12 +1082,12 @@ protected async Task HandleCommentHelpRequest(
10821082
{
10831083
var scriptFile = EditorSession.Workspace.GetFile(requestParams.DocumentUri);
10841084
var expectedFunctionLine = requestParams.TriggerPosition.Line + 2;
1085+
10851086
string helpLocation;
10861087
var functionDefinitionAst = EditorSession.LanguageService.GetFunctionDefinitionForHelpComment(
10871088
scriptFile,
10881089
requestParams.TriggerPosition.Line + 1,
10891090
out helpLocation);
1090-
10911091
var result = new CommentHelpRequestResult();
10921092
if (functionDefinitionAst != null)
10931093
{
@@ -1100,7 +1100,6 @@ protected async Task HandleCommentHelpRequest(
11001100
requestParams.BlockComment,
11011101
true,
11021102
helpLocation));
1103-
11041103
result.Content = analysisResults?
11051104
.FirstOrDefault()?
11061105
.Correction?
@@ -1109,10 +1108,11 @@ protected async Task HandleCommentHelpRequest(
11091108
.Split('\n')
11101109
.Select(x => x.Trim('\r'))
11111110
.ToArray();
1112-
1113-
if (helpLocation.Equals("begin", StringComparison.OrdinalIgnoreCase))
1111+
if (helpLocation != null &&
1112+
!helpLocation.Equals("before", StringComparison.OrdinalIgnoreCase))
11141113
{
1115-
// we need to trim the leading `{` that the correction sends.
1114+
// we need to trim the leading `{` and newline when helpLocation=="begin"
1115+
// we also need to trim the leading newline when helpLocation=="end"
11161116
result.Content = result.Content?.Skip(1).ToArray();
11171117
}
11181118
}

0 commit comments

Comments
 (0)