StyLua icon indicating copy to clipboard operation
StyLua copied to clipboard

Long function with multiple generic return types formats inconsistently

Open Great-Bird opened this issue 1 year ago • 0 comments

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

Great-Bird avatar Sep 27 '24 22:09 Great-Bird