Skip to content

Show variant constructor's inline record types on hover #7519

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

Merged
merged 6 commits into from
May 24, 2025

Conversation

mediremi
Copy link
Contributor

image

Hovering a variant constructor currently only shows payload type information if it uses arguments, but not if it has an inline record:

let argsString =
match args with
| InlineRecord _ | Args [] -> ""
| Args args ->
args
|> List.map (fun (t, _) -> Shared.typeToString t)
|> String.concat ", " |> Printf.sprintf "(%s)"
in
typeString :: Markdown.codeBlock (txt ^ argsString) :: docstring

My first commit fixes this by using CompletionBackEnd.showConstructor.

My second commit moved where we show constructor payload type information from the end of the markdown hover text to instead be right after the name of the variant type. This allows users to see payload type information immediately instead of having to scroll through related types first.

This also matches the behaviour of other LSPs, like rust-analyzer:
rust-analyzer screenshot

@mediremi mediremi marked this pull request as ready for review May 24, 2025 16:38
Copy link

pkg-pr-new bot commented May 24, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7519

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7519

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7519

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7519

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7519

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7519

commit: ff9bc9e

@zth zth self-requested a review May 24, 2025 17:41
Copy link
Collaborator

@zth zth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, this is great! Keep them coming 😄

Also, feel free to request review from me whenever.

@zth zth merged commit f985ab1 into rescript-lang:master May 24, 2025
16 checks passed
@mediremi
Copy link
Contributor Author

Thanks, will do! 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants