DanielGavin / ols

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

Stroustrup brace style inserting extra space in front of else #394

Open cstrachan88 opened 4 months ago

cstrachan88 commented 4 months ago

The Stroustrup brace style is broken. I believe this used to work correctly. In the latest version of OLS, an extra space is inserted before the else:

    x := 1
    if x == 1 {
        // do somtehing
    }
     else if x == 2 {
        // do something 2
    }
     else {
        // do something else
    }

Should instead be:

    x := 1
    if x == 1 {
        // do somtehing
    }
    else if x == 2 {
        // do something 2
    }
    else {
        // do something else
    }

This is my current odinfmt.json:

{
    "$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/odinfmt.schema.json",
    "character_width": 140,
    "tabs": false,
    "spaces": 4,
    "newline_limit": 4,
    "indent_cases": true,
    "brace_style": "Stroustrup"
}
cstrachan88 commented 3 months ago

The brace style is also not respected for when blocks. The following is also the formatted code using the same odinfmt.json above.

CONST_BOOL :: true
when CONST_BOOL {
    // something
} else {
    // something else
}

if CONST_BOOL {
    // something
}
 else {
    // something else
}