@@ -1063,32 +1063,43 @@ protected async Task HandleCommentHelpRequest(
10631063 RequestContext < CommentHelpRequestResult > requestContext )
10641064 {
10651065 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 ;
10671068
10681069 string helpLocation ;
1069- var functionDefinitionAst = this . editorSession . LanguageService . GetFunctionDefinitionForHelpComment (
1070+ var functionDefinitionAst = editorSession . LanguageService . GetFunctionDefinitionForHelpComment (
10701071 scriptFile ,
1071- requestParams . TriggerPosition . Line + 1 ,
1072+ triggerLine1b ,
10721073 out helpLocation ) ;
10731074 var result = new CommentHelpRequestResult ( ) ;
10741075 if ( functionDefinitionAst != null )
10751076 {
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+
10761093 var analysisResults = await this . editorSession . AnalysisService . GetSemanticMarkersAsync (
1077- functionDefinitionAst . Extent . Text ,
1094+ funcText ,
10781095 AnalysisService . GetCommentHelpRuleSettings (
10791096 true ,
10801097 false ,
10811098 requestParams . BlockComment ,
10821099 true ,
10831100 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 ( ) ;
10921103 if ( helpLocation != null &&
10931104 ! helpLocation . Equals ( "before" , StringComparison . OrdinalIgnoreCase ) )
10941105 {
0 commit comments