Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AP signatures for APs with names which are substrings of other APs #1211

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/FsAutoComplete.Core/SignatureFormatter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,12 @@ module SignatureFormatter =

let getAPCaseSignature displayContext (apc: FSharpActivePatternCase) =
let findVal =
let apcSearchString = $"|{apc.DisplayName}|"

apc.Group.DeclaringEntity
|> Option.bind (fun ent ->
ent.MembersFunctionsAndValues
|> Seq.tryFind (fun func -> func.DisplayName.Contains apc.DisplayName)
|> Seq.tryFind (fun func -> func.DisplayName.Contains(apcSearchString, StringComparison.OrdinalIgnoreCase))
|> Option.map (getFuncSignature displayContext))
|> Option.bind (fun n ->
try
Expand Down
23 changes: 22 additions & 1 deletion test/FsAutoComplete.Tests.Lsp/CoreTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,28 @@ let tooltipTests state =
" body : (MailboxProcessor<string> -> Async<unit>) *"
" cancellationToken: option<System.Threading.CancellationToken>"
" -> MailboxProcessor<string>" ])
verifySignature 54 9 "Case2 of string * newlineBefore: bool * newlineAfter: bool" ] ]
verifySignature 54 9 "Case2 of string * newlineBefore: bool * newlineAfter: bool"
verifySignature
60
7
(concatLines
[ "active pattern Value: "
" input: Expr"
" -> option<obj * System.Type>" ])
verifySignature
65
7
(concatLines
[ "active pattern DefaultValue: "
" input: Expr"
" -> option<System.Type>" ])
verifySignature
70
7
(concatLines
[ "active pattern ValueWithName: "
" input: Expr"
" -> option<obj * System.Type * string>" ]) ] ]

let closeTests state =
// Note: clear diagnostics also implies clear caches (-> remove file & project options from State).
Expand Down
17 changes: 17 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/TestCases/Tooltips/Script.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,20 @@ let mailbox =
type DiscUnionWithCaseOfLabeledTuple =
| Case1
| Case2 of string * newlineBefore: bool * newlineAfter: bool

open FSharp.Quotations.Patterns

let testActivePatternSignatureWithSubStringName (expr: Quotations.Expr) =
match expr with
| Value (o, t) -> (o, t)
| _ -> failwith "no value match"
|> ignore

match expr with
| DefaultValue t -> t
| _ -> failwith "no value match"
|> ignore

match expr with
| ValueWithName t -> t
| _ -> failwith "no value match"
Loading