Skip to content

Incorrect indentation when using alternate php syntax #171

@kanlukasz

Description

@kanlukasz

Code before formatting:

image

Code after formatting:

image

Correctly the code should look like this:

image

Environment for tests:

  • VsCode Version: 1.72.2
  • PHP Tools v1.18.10878 Pre-Release
  • OS Name: Microsoft Windows 11 Pro
  • OS Version: 10.0.22621 N/A Build 22621

VSCode settings:

{
    "workbench.colorTheme": "Darcula",
    "php.suggest.basic": false,
    "php.validate.enable": false,
    "emmet.excludeLanguages": [
        "markdown",
        "php"
    ],
    "php.problems.exclude": {
        "wp-admin/": true,
        "wp-includes/": true,
        "wp-content/plugins/": true,
        "vendor/": true,
    },
    "php.codeLens.enabled": false
}

Another example:

Before formatting:

<?php echo 'Head'; ?>

<?php if ($q = true) : ?>
    <?php while ($v = true) :  ?>
        <section>
            <?php if ($q = true) : ?>
                <?php while ($v = true) :  ?>
                    <div>Hello</div>
                    <div>Hello</div>
                    <div>Hello</div>
                    <div>Hello</div>
                    <div>Hello</div>
                    <div>Hello</div>
                <?php endwhile; ?>
            <?php endif; ?>
        </section>
    <?php endwhile; ?>
<?php else : ?>
    <?php echo 'Lorem ipsum'; ?>
<?php endif; ?>

<?php echo 'Foot'; ?>

After formatting:

<?php echo 'Head'; ?>

<?php if ($q = true): ?>
<?php while ($v = true): ?>
<section>
    <?php if ($q = true): ?>
    <?php while ($v = true): ?>
    <div>Hello</div>
    <div>Hello</div>
    <div>Hello</div>
    <div>Hello</div>
    <div>Hello</div>
    <div>Hello</div>
    <?php endwhile; ?>
    <?php endif; ?>
</section>
<?php endwhile; ?>
<?php else: ?>
<?php echo 'Lorem ipsum'; ?>
<?php endif; ?>

<?php echo 'Foot'; ?>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions