diff --git a/vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs b/vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs index ca12c191f96ac9c36f90cb56f8293f0f8e5c2934..77ea933f22782d3edc20feeb2da12d27c2274a47 100644 --- a/vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs +++ b/vsintegration/src/FSharp.Editor/Hints/InlineParameterNameHints.fs @@ -9,6 +9,7 @@ open FSharp.Compiler.EditorServices open FSharp.Compiler.Symbols open FSharp.Compiler.Text open Hints +open Microsoft.VisualStudio.FSharp.Editor module InlineParameterNameHints = @@ -56,10 +57,8 @@ module InlineParameterNameHints = >> Seq.contains range let private getSourceTextAtRange (sourceText: SourceText) (range: range) = - - let line = sourceText.Lines[ range.Start.Line - 1 ].ToString() - let length = range.EndColumn - range.StartColumn - line.Substring(range.Start.Column, length) + (RoslynHelpers.FSharpRangeToTextSpan(sourceText, range) |> sourceText.GetSubText) + .ToString() let isMemberOrFunctionOrValueValidForHint (symbol: FSharpMemberOrFunctionOrValue) (symbolUse: FSharpSymbolUse) = diff --git a/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs b/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs index 7a44467afcf9e2a2642b929c5548e46dd8dcf322..46805aea480e23e08e372a6234c23c9e03986c97 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs @@ -494,7 +494,7 @@ let q = query { for x in { 1 .. 10 } do select x } Assert.Empty actual [] - let ``Hints are not shown when parameter names coinside with variable names`` () = + let ``Hints are not shown when parameter names coincide with variable names`` () = let code = """ let getFullName name surname = $"{name} {surname}" @@ -517,3 +517,28 @@ let fullName = getFullName name lastName let actual = getParameterNameHints document Assert.Equal(expected, actual) + + [] + let ``Hints don't break with multi-line arguments`` () = + let code = + """ +None +|> Option.map (fun x -> + x + 5 + ) +|> ignore + """ + + let document = getFsDocument code + + let expected = + [ + { + Content = "mapping = " + Location = (2, 15) + } + ] + + let actual = getParameterNameHints document + + Assert.Equal(expected, actual)