未验证 提交 18c79cff 编写于 作者: P Petr Pokorny 提交者: GitHub

Fix parameter name hints crashing with multi-line arguments (#15004)

上级 d71fde98
......@@ -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) =
......
......@@ -494,7 +494,7 @@ let q = query { for x in { 1 .. 10 } do select x }
Assert.Empty actual
[<Fact>]
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)
[<Fact>]
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)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册