DanielGavin / ols

Language server for Odin
MIT License
439 stars 67 forks source link

[odinfmt] Struct formatting is broken when there are many `where` cases #391

Open jakubtomsu opened 4 months ago

jakubtomsu commented 4 months ago

Here is an example of code which has very broken formatting:

Indirect_Array :: struct($Num: int, $Index, $Gen, $Val: typeid) #align(64)
where intrinsics.type_is_integer(Index) &&
    Num > 0 &&
    (1 << (size_of(Index) * 8) >= Num) &&
    (size_of(Gen) == 0 || intrinsics.type_is_unsigned(Gen))
{
    len: Index,
    pool: Pool(Num, Index, Gen, Index),
    indexes: [Num]Index,
    values: [Num]Val,
    invalid_value: Val,
}

Which formats into:

Indirect_Array :: struct($Num: int,
$Index, $Gen, $Val: typeid,) #align (64) where intrinsics.type_is_integer(Index) &&
    Num > 0 &&
    (1 << (size_of(Index) * 8) >= Num) &&
    (size_of(Gen) == 0 || intrinsics.type_is_unsigned(Gen))
{
    len:          
    Index,
    pool:         
    Pool(Num, Index, Gen, Index),
    indexes:      
    [Num]Index,
    values:       
    [Num]Val,
    invalid_value:
    Val,
}

Notice the additional comma after the struct args, and the field types on a new line.

DanielGavin commented 4 months ago

Yeah don't think that is even really implemented. It'll most likely have to be treated like the procedures.