First: thanks for the prompt fixes on the previous auto-format errors I reported. Format is working much more reliably in the codebases I'm working from, now!

I've got a new one for you, and this one's quite weird:

<div>
    <div
      class="zzzzz zzzzz zzzzzz zzzzzzz zzzzzz zzzzzzzz zzzzzzz zzzzzzzzz zzzzzzz zzzzzzzzz zzzzzzz zzzzz zzzzzz zzzzz">
      <div>
          <div>
                        <span><?= 1 ?></span>
                        text
        </div>
</div>
</div>

</div>

This fails with "Format stopped. Change is not allowed. [Line 7]"

Things that affect it:

  • Length of the class on line 3. One character shorter, and it formats. One character longer, and it doesn't. It doesn't matter if there are spaces or not, that just happens to be the version I'm sharing (replacing spaces with zs exhibits the same behavior, though the length might vary by a character or two)
  • Indentation: if you indent or de-indent the </div> on line 8 by one space, it formats
  • Wrapping / parent child classes: I tried to get the minimal reproduction, but due to the above items I couldn't simplify it more easily. Removing wrapping classes might succeed only because of whatever is causing it to fail based on the whitespace.
  • PHP tag: this can be either <?php ?> or <?= ?>, but if you remove it, formatting works
  • Text node: delete this, and formatting works (with or without the preceding space)

Hopefully this is enough info to run it down, and maybe it will lead to a broader fix :) While I was attempting to get the last 3-ish files in shape (trying to see if there was an easy workaround, which I initially thought might be converting <?php ?> to <?= ?>), one of them "magically" started formatting correctly, and I think it's a similar situation with the indentation.

    This is so small that it doesn't quite deserve its own thread, but again is on the auto-format topic:

    The option to keep statements on the same line for conditionals doesn't produce consistent spacing:

      if (true) return;
      if (true)$foo = 'bar';

    (personally, I prefer it with the space, but the inconsistency means I don't want to use the option at all...)

      Hi Kris,

      Thank you for providing us with more cases. We're going to take a look at each of those and get back to you.

      Arturust seems to be a bot, removed.

        Hi Kris,

        The issue with control flow statements in one line has been fixed. It will be available in the pre-release.

        Thank you!

        Hi Kris,

        Thank you again for your continuous feedback. In the upcoming preview, there will be a fix for the original issue of this thread.

        It's actually caused by a weird behavior of VSC HTML formatter which we use. One "ultimate fix" of these html/php formatting issues would be to use our HTML formatter, which we actually have. But it would behave differently than VSC HTML formatter. And we really like to be as compatible as possible.

        We will see how it goes after this fix :-)

        Cheers!

          Interesting. I wouldn't be averse to using a different HTML formatter, so long as it doesn't behave like the "Format HTML in PHP" extension, which basically re-saves a document after you save it and interferes with undo, etc. I assume if you have an HTML formatter extension, it integrates nicely with your PHP formatting? What do I need to do?

            (Unrelated: do you have a Discord or a Slack or something? Forums are fine, but not the most useful for small back and forths)

              Thanks for your input!

              I meant we have HTML formatter as a component we used in a different project. But it's not released in any VSC extension, we will see if we'll use it in the future.

              We do not have slack or discord... or at least not yet :-)

                22 days later
                • Edited

                I have the same problem with the following line, even in the preview version.

                <a class="btn btn-outline-cms-gray" href="index.php?page=communication-systems-edit&submenu=<?php echo $_GET['submenu']; ?>&communicationID=<?php echo $communication['method_id'];
                										   echo (isset($langlink) and $langlink) ? '&'.$langlink : NULL;
                										   echo (isset($admin_site) and $admin_site) ? '&'.$admin_site : NULL; ?>" role="button" <?php echo (!site_rights(__FILE__, 'edit')) ? ' hidden' : NULL; ?>><i class="fas fa-pencil-alt"></i></a>
                • Edited

                DP24 If I remove the i-tag, it continues, as if it doesn't properly understand the tag and resolves it.

                Sometimes the <i class="fas fa-pencil-alt"></i> becomes < i class="fas fa-pencil-alt"></i>

                  DP24 Is this line giving you Change is not allowed. ? Could you please specify what the issue is? (this thread had multiple issues in one).

                    DP24 We found a bug surfacing when formatting the snippet you've provided. Fix will be present in the upcoming pre-release. Thank you!

                      This one should be fixed in the latest pre-release. Closing

                      Thank you! Please feel free to open a new one if you run into anything else.

                      Write a Reply...