DanielGavin / ols

Language server for Odin
MIT License
382 stars 58 forks source link

Comments in Function Signature Parameters Are Formatted Incorrectly #422

Closed dozn closed 1 week ago

dozn commented 2 weeks ago

Start with

package main
some_long_type_name_to_force_vertical_parameter_formatting :: int
a :: proc(
    a: some_long_type_name_to_force_vertical_parameter_formatting,
        // test
    i: some_long_type_name_to_force_vertical_parameter_formatting,
)
{
}

hit save, and it will turn into

package main
some_long_type_name_to_force_vertical_parameter_formatting :: int
a :: proc(
    a: some_long_type_name_to_force_vertical_parameter_formatting,
    i: some_long_type_name_to_force_vertical_parameter_formatting,// test
) {
}

then hit save again, and you'll get

package main
some_long_type_name_to_force_vertical_parameter_formatting :: int
a :: proc(
    a: some_long_type_name_to_force_vertical_parameter_formatting,
    i: some_long_type_name_to_force_vertical_parameter_formatting,
) // test
{
}

which on top of being incorrect, also violates the 1TBS style (using -strict-style) ;D

DanielGavin commented 1 week ago

Should be fixed.

dozn commented 1 week ago

Sort of =b

For the first example, it now removes the trailing comma:

package main
some_long_type_name_to_force_vertical_parameter_formatting :: int
a :: proc(
    a: some_long_type_name_to_force_vertical_parameter_formatting,
    // test
    i: some_long_type_name_to_force_vertical_parameter_formatting <-- Trailing comma gets removed
) {
}

The second example is still broken as when you save the following, the comment will be incorrectly pushed down a line.

package main
some_long_type_name_to_force_vertical_parameter_formatting :: int
a :: proc(
    a: some_long_type_name_to_force_vertical_parameter_formatting,
    i: some_long_type_name_to_force_vertical_parameter_formatting, // test
) {
}

Appreciate you!

DanielGavin commented 1 week ago

Thanks.

Both examples are hopefully fixed now.

dozn commented 1 week ago

You're the best, all good!