zed icon indicating copy to clipboard operation
zed copied to clipboard

c: Fix incorrect indentation after `if` statements

Open Louis-Ladd opened this issue 1 year ago • 4 comments

  • Closes #13924

Release Notes:

  • curly braces won't indent after If, else if, else

Louis-Ladd avatar Oct 09 '24 18:10 Louis-Ladd

We require contributors to sign our Contributor License Agreement, and we don't have @Louis-Ladd on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

cla-bot[bot] avatar Oct 09 '24 18:10 cla-bot[bot]

@cla-bot check

Louis-Ladd avatar Oct 09 '24 18:10 Louis-Ladd

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar Oct 09 '24 18:10 cla-bot[bot]

This PR fails the test_c_autoindent

if ()
{

}
if () {

}

Running the build myself and testing both styles correctly indents for me so I'm not sure why it's failing that test.

Louis-Ladd avatar Oct 09 '24 19:10 Louis-Ladd

The issue is that whilst your described cases now work properly, the case originally causing this behavior stopped working with your changes.

This is the case

if ()
    single_statement_to_be_executed

which is an if-statement with just a single statement and without brackets.

The removal of this auto-indentation is also what fails the tests. The issue you referenced also stated that the indentation should only be removed once brackets are inserted.

MrSubidubi avatar Oct 11 '24 12:10 MrSubidubi

Looks quite stale, so will close this.

SomeoneToIgnore avatar Nov 05 '24 11:11 SomeoneToIgnore