Skip to content

Commit

Permalink
fix func signature for empty param names (#1351)
Browse files Browse the repository at this point in the history
* fix func signature for empty param names

* add testcase
  • Loading branch information
dawedawe authored Jan 24, 2025
1 parent ed1bcf7 commit 9277ff9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/FsAutoComplete.Core/SignatureFormatter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,13 @@ module SignatureFormatter =
many
|> List.map (fun (paramTypes) ->
paramTypes
|> List.map (fun p -> formatName p + ":" ++ (formatParameter p))
|> List.map (fun p ->
let paramName = formatName p

if String.IsNullOrWhiteSpace(paramName) then
formatParameter p
else
paramName + ":" ++ (formatParameter p))
|> String.concat (" * "))
|> String.concat (" -> ")

Expand Down
11 changes: 9 additions & 2 deletions test/FsAutoComplete.Tests.Lsp/CoreTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,19 @@ let tooltipTests state =
#if NET8_0
[ "active pattern ValueWithName: "
" input: Expr"
" -> option<obj * System.Type * string>" ]) ] ]
" -> option<obj * System.Type * string>" ])
#else
[ "active pattern ValueWithName: "
" input: Expr"
" -> option<objnull * System.Type * string>" ]) ] ]
" -> option<objnull * System.Type * string>" ])
#endif
verifySignature
96u
7u
(concatLines
[ "interface IWithAndWithoutParamNames"
" abstract member WithParamNames: arg1: int * arg2: float -> string"
" abstract member WithoutParamNames: int * string -> int" ]) ] ]

let closeTests state =
// Note: clear diagnostics also implies clear caches (-> remove file & project options from State).
Expand Down
4 changes: 4 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/TestCases/Tooltips/Script.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,7 @@ type Awaitable =
(awaitable: 'Awaitable)
=
awaitable.GetAwaiter()

type IWithAndWithoutParamNames =
abstract member WithParamNames : arg1: int * arg2: float -> string
abstract member WithoutParamNames : int * string -> int

0 comments on commit 9277ff9

Please sign in to comment.