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

render optional args as ?name: type instead of name: option<type> #1297

Merged
merged 3 commits into from
May 21, 2024
Merged
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion src/FsAutoComplete.Core/SignatureFormatter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ module SignatureFormatter =
let safeParameterName (p: FSharpParameter) =
match Option.defaultValue p.DisplayNameCore p.Name with
| "" -> ""
| name -> FSharpKeywords.NormalizeIdentifierBackticks name
| name ->
let n = FSharpKeywords.NormalizeIdentifierBackticks name
if p.IsOptionalArg then "?" + n else n // render optional args as "?ident: type"

let padLength =
let allLengths =
Expand Down Expand Up @@ -291,6 +293,8 @@ module SignatureFormatter =

if p.Type.IsFunctionType then
$"({formatted})"
else if p.IsOptionalArg && formatted.StartsWith("option<", StringComparison.Ordinal) then // render optional args as "?ident: type"
formatted.Substring(7).TrimEnd('>')
baronfel marked this conversation as resolved.
Show resolved Hide resolved
else
formatted
with :? InvalidOperationException ->
Expand Down
Loading