Skip to content

Long function with multiple generic return types formats inconsistently #896

@Great-Bird

Description

@Great-Bird

A column width-exceeding function definition with multiple return types with generics collapses over one of the type parameters instead of placing each return type on a new line.

Before and after:

-- before
local function getData(player: Player): (LongReturnValueWithTypeGeneric1<TypeParameter1>, LongReturnValueWithTypeGeneric2<TypeParameter2>) end

-- after
local function getData(player: Player): (LongReturnValueWithTypeGeneric1<TypeParameter1>, LongReturnValueWithTypeGeneric2<
	TypeParameter2
>) end

-- expected
local function getData(player: Player): (
	LongReturnValueWithTypeGeneric1<TypeParameter1>,
	LongReturnValueWithTypeGeneric2<TypeParameter2>
) end

Example of expected output working for a similar example:

-- before
local function getData(player: Player): (LongReturnValueNameWithoutTypeGeneric1, LongReturnValueNameWithoutTypeGeneric2, LongReturnValueNameWithoutTypeGeneric3) end

-- after & expected
local function getData(player: Player): (
	LongReturnValueNameWithoutTypeGeneric1,
	LongReturnValueNameWithoutTypeGeneric2,
	LongReturnValueNameWithoutTypeGeneric3
) end

stylua.toml:

column_width = 120
line_endings = "Windows"
indent_type = "Tabs"
indent_width = 4
quote_style = "AutoPreferDouble"
call_parentheses = "NoSingleTable"
collapse_simple_statement = "Never"

[sort_requires]
enabled = true

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestluauFormatting related to Luau

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions