@@ -226,24 +226,10 @@ type internal FSharpSignatureHelpProvider
226226 documentationBuilder : IDocumentationBuilder ,
227227 sourceText : SourceText ,
228228 caretPosition : int ,
229+ adjustedColumnInSource : int ,
229230 filePath : string
230231 ) =
231232 asyncMaybe {
232- // Backtrack to find a non-whitespace character to get curried arg infos (if present) and a symbol to inspect.
233- let adjustedColumnInSource =
234- let rec loop s c =
235- if String.IsNullOrWhiteSpace( s.ToString()) then
236- loop ( sourceText.GetSubText( c - 1 )) ( c - 1 )
237- else
238- c
239- let startText =
240- if caretPosition = sourceText.Length then
241- sourceText.GetSubText( caretPosition)
242- else
243- sourceText.GetSubText( TextSpan( caretPosition, 1 ))
244-
245- loop startText caretPosition
246-
247233 let textLine = sourceText.Lines.GetLineFromPosition( adjustedColumnInSource)
248234 let textLinePos = sourceText.Lines.GetLinePosition( adjustedColumnInSource)
249235 let pos = mkPos ( Line.fromZ textLinePos.Line) textLinePos.Character
@@ -465,19 +451,28 @@ type internal FSharpSignatureHelpProvider
465451 let perfOptions = document.FSharpOptions.LanguageServicePerformance
466452
467453 let! parseResults , _ , checkFileResults = checker.ParseAndCheckDocument( filePath, textVersionHash, sourceText, options, perfOptions, userOpName = userOpName)
468- match parseResults.FindNoteworthyParamInfoLocations( Pos.fromZ caretLinePos.Line caretLineColumn) with
469- | Some paramInfoLocations ->
470- return !
471- FSharpSignatureHelpProvider.ProvideMethodsAsyncAux(
472- caretLinePos,
473- caretLineColumn,
474- paramInfoLocations,
475- checkFileResults,
476- documentationBuilder,
477- sourceText,
478- caretPosition,
479- triggerTypedChar)
480- | None ->
454+
455+ let adjustedColumnInSource =
456+ let rec loop s c =
457+ if String.IsNullOrWhiteSpace( s.ToString()) then
458+ loop ( sourceText.GetSubText( c - 1 )) ( c - 1 )
459+ else
460+ c
461+ let startText =
462+ if caretPosition = sourceText.Length then
463+ sourceText.GetSubText( caretPosition)
464+ else
465+ sourceText.GetSubText( TextSpan( caretPosition, 1 ))
466+
467+ loop startText caretPosition
468+
469+ let adjustedColumnString = sourceText.GetSubText( TextSpan( adjustedColumnInSource, 1 )). ToString()
470+
471+ match triggerTypedChar with
472+ // Generally ' ' indicates a function application, but it's also used commonly after a comma in a method call.
473+ // This means that the adjusted position relative to the caret could be a ',' or a ')' or '>',
474+ // which would mean we're already inside of a method call - not a function argument. So we bail if that's the case.
475+ | Some ' ' when adjustedColumnString <> " ," && adjustedColumnString <> " )" && adjustedColumnString <> " >" ->
481476 return !
482477 FSharpSignatureHelpProvider.ProvideParametersAsyncAux(
483478 parseResults,
@@ -487,7 +482,20 @@ type internal FSharpSignatureHelpProvider
487482 documentationBuilder,
488483 sourceText,
489484 caretPosition,
485+ adjustedColumnInSource,
490486 filePath)
487+ | _ ->
488+ let! paramInfoLocations = parseResults.FindNoteworthyParamInfoLocations( Pos.fromZ caretLinePos.Line caretLineColumn)
489+ return !
490+ FSharpSignatureHelpProvider.ProvideMethodsAsyncAux(
491+ caretLinePos,
492+ caretLineColumn,
493+ paramInfoLocations,
494+ checkFileResults,
495+ documentationBuilder,
496+ sourceText,
497+ caretPosition,
498+ triggerTypedChar)
491499 }
492500
493501 interface IFSharpSignatureHelpProvider with
0 commit comments