code-biscuits / assorted-biscuits

https://marketplace.visualstudio.com/items?itemName=CodeBiscuits.assorted-biscuits
MIT License
6 stars 1 forks source link

PHP Biscuit doesn't handle brackets on new lines well #7

Open mwnciau opened 3 years ago

mwnciau commented 3 years ago

e.g.

if ( $success )
{
    $newDonor = $_POST['SERIALNUMBER'];
}

Shows the biscuit:

image

Presumably an issue in other languages, too, where the coding style is to place brackets on a new line.

mwnciau commented 3 years ago

On a second look, this might be intended behaviour, but nonetheless I find it confusing. This only happens after the if block in an if-else statement.

image

It seems more intuitive to me that the // if ( $condition ) should come at the end of the if block, not at the end of the else block.

cmgriffing commented 3 years ago

Yeah, I agree. The output will need some fine tuning. That is my mistake. My testing dataset just doesn't have that formatting in it. I will work on that this weekend probably.

cmgriffing commented 3 years ago

I did some fiddling.

Here is the result: Screen Shot 2021-08-29 at 5 23 22 PM

It isn't perfect, but I think it improves on the else with brackets on the same line as well. I'm thinking the if being shown on the very last part of an else is intended at this point. We just annotate the middle bracket now too.

If you want to toy around with it more, I have a working branch going: https://github.com/code-biscuits/assorted-biscuits/tree/language-specific-filters

If you think its good enough, I can get a release out after some cleanup.