@@ -1063,32 +1063,43 @@ protected async Task HandleCommentHelpRequest(
1063
1063
RequestContext < CommentHelpRequestResult > requestContext )
1064
1064
{
1065
1065
var scriptFile = this . editorSession . Workspace . GetFile ( requestParams . DocumentUri ) ;
1066
- var expectedFunctionLine = requestParams . TriggerPosition . Line + 2 ;
1066
+ var triggerLine0b = requestParams . TriggerPosition . Line ;
1067
+ var triggerLine1b = triggerLine0b + 1 ;
1067
1068
1068
1069
string helpLocation ;
1069
- var functionDefinitionAst = this . editorSession . LanguageService . GetFunctionDefinitionForHelpComment (
1070
+ var functionDefinitionAst = editorSession . LanguageService . GetFunctionDefinitionForHelpComment (
1070
1071
scriptFile ,
1071
- requestParams . TriggerPosition . Line + 1 ,
1072
+ triggerLine1b ,
1072
1073
out helpLocation ) ;
1073
1074
var result = new CommentHelpRequestResult ( ) ;
1074
1075
if ( functionDefinitionAst != null )
1075
1076
{
1077
+ var funcExtent = functionDefinitionAst . Extent ;
1078
+ var funcText = funcExtent . Text ;
1079
+ if ( helpLocation . Equals ( "begin" ) )
1080
+ {
1081
+ // check if the previous character is `<` because it invalidates
1082
+ // the param block the follows it.
1083
+ var lines = ScriptFile . GetLines ( funcText ) . ToArray ( ) ;
1084
+ var relativeTriggerLine0b = triggerLine1b - funcExtent . StartLineNumber ;
1085
+ if ( relativeTriggerLine0b > 0 && lines [ relativeTriggerLine0b ] . IndexOf ( "<" ) > - 1 )
1086
+ {
1087
+ lines [ relativeTriggerLine0b ] = string . Empty ;
1088
+ }
1089
+
1090
+ funcText = string . Join ( "\n " , lines ) ;
1091
+ }
1092
+
1076
1093
var analysisResults = await this . editorSession . AnalysisService . GetSemanticMarkersAsync (
1077
- functionDefinitionAst . Extent . Text ,
1094
+ funcText ,
1078
1095
AnalysisService . GetCommentHelpRuleSettings (
1079
1096
true ,
1080
1097
false ,
1081
1098
requestParams . BlockComment ,
1082
1099
true ,
1083
1100
helpLocation ) ) ;
1084
- result . Content = analysisResults ?
1085
- . FirstOrDefault ( ) ?
1086
- . Correction ?
1087
- . Edits [ 0 ]
1088
- . Text
1089
- . Split ( '\n ' )
1090
- . Select ( x => x . Trim ( '\r ' ) )
1091
- . ToArray ( ) ;
1101
+ var help = analysisResults ? . FirstOrDefault ( ) ? . Correction ? . Edits [ 0 ] . Text ;
1102
+ result . Content = help == null ? null : ScriptFile . GetLines ( help ) . ToArray ( ) ;
1092
1103
if ( helpLocation != null &&
1093
1104
! helpLocation . Equals ( "before" , StringComparison . OrdinalIgnoreCase ) )
1094
1105
{
0 commit comments