Skip to content

Option to have inlay hints for trailing closures #2381

@RowSalmon

Description

@RowSalmon

Description

Hello, im hoping for inlay hints to be shown for trailing closures. I often have trouble working out what parameter the trailing closure is for - and an inlay hint would be a great way to help me out here. I'm sure other beginners learning swift would also appreciate this feature.

An example (from Apples' NavigationCookBook example project):

        .sheet(isPresented: $navigationModel.showExperiencePicker) {
            ExperiencePicker(experience: $experience)
        }

The function signature for .sheet is

func sheet<Content>(
    isPresented: Binding<Bool>,
    onDismiss: (() -> Void)? = nil,
    @ViewBuilder content: @escaping () -> Content
) -> some View where Content : View

Its not immediately clear to a beginner whether the trailing closure relates to onDismiss or content.

The enhancement here would be to add an inlay hint as follows:

        .sheet(isPresented: $navigationModel.showExperiencePicker) : content {
            ExperiencePicker(experience: $experience)
        }

Those proficient with swift may find inlay hints here unnecessarily verbose - and that is why i'm proposing this be an optional toggle feature (consistent with how other LSPs allow granular control over what type of inlay hints are shown and which ones are not)

Thank you for your consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions