DEVSENSE / phptools-docs

PHP Tools public content
Apache License 2.0
75 stars 9 forks source link

One-line conditional echo statement causes incorrect syntax highlighting and formatting in VSCode #576

Open alexanderroidl opened 3 weeks ago

alexanderroidl commented 3 weeks ago

The following PHP code...

<?php for ($p = $pages; $p > 0; $p--): ?>
    <li<?= ($gb_page == $p) ? ' class="active"' : ''; ?>>
        <a href="index.php?page=gb&gbpage=<?= $p; ?>"><?= $p; ?></a>
    </li>
<?php endfor; ?>

...is getting formatted like this...

<?php for ($p = $pages; $p > 0; $p--): ?>
    <li<?= ($gb_page == $p) ? ' class="active"' : ''; ?>>
        <a href="index.php?page=gb&gbpage=<?= $p; ?>"><?= $p; ?></a>
        </li>
    <?php endfor; ?>

...while also being highlighted like this (see line 2): Screenshot from 2024-06-14 13-25-09

System info OS: Ubuntu 24.04 LTS
PHP version: 8.3.6
Visual Studio Code version: 1.90.0 89de5a8d4d6205e5b11647eb6a74844ca23d2573 x64
phptools-vscode version: 1.47.15512
jakubmisek commented 3 weeks ago

Thank you for reporting the issues.

Miloslav commented 3 weeks ago

Quick hotfix for both issues would be to change the code, so there is a space after <li :

<?php for ($p = $pages; $p > 0; $p--): ?>
    <li <?= ($gb_page == $p) ? 'class="active"' : ''; ?>>
        <a href="index.php?page=gb&gbpage=<?= $p; ?>"><?= $p; ?></a>
    </li>
<?php endfor; ?>

Anyway, we will try to handle it on our end too.

Thanks

alexanderroidl commented 2 weeks ago

Thanks to both of you @Miloslav and @jakubmisek. I will post an issue in the VSCode repository sometime soon as well. Your work is much appreciated!