Page 1 of 1

Problem formatting html when php code exists

PostPosted: January 14th, 2018, 5:26 pm
by Sachelis
If I have an unformatted *.php file that contains a php tag:
Code: Select all
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test Page</title>
<?php ?>
</head>
<body>
<p>This is text and <a href="test.php">this</a> is a link.</p>
</body>
</html>

and I format it (Edit | Advanced | Format Document, aka Ctrl-K, Ctrl-D), it messes up the formatting. The fatal problem is that it removes the space after the "</a>" tag, in this case creating the word "thisis":
Code: Select all
<!DOCTYPE html>
<html lang="en">
<head>
   <title>Test Page</title>
   <?php ?>
</head>
<body>
   <p>
      This is text and
      <a href="test.php">this</a>is a link.
   </p>
</body>
</html>

Note that if I remove the php tag:
Code: Select all
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test Page</title>
</head>
<body>
<p>This is text and <a href="test.php">this</a> is a link.</p>
</body>
</html>

and format it, the formatting is correct:
Code: Select all
<!DOCTYPE html>
<html lang="en">
<head>
   <title>Test Page</title>
</head>
<body>
   <p>This is text and <a href="test.php">this</a> is a link.</p>
</body>
</html>

Note that this problem doesn't occur if PHP Tools is disabled and the file has an *.htm extension (in which case the formatting is "normal"). If PHP Tools is disabled and the file has a *.php extension, no formatting takes place.

This problem occurs regardless of where the php tag is in the file. It occurs if the contents of the php block is blank (as in the above examples), if it only contains a comment, or if it contains php code.

I'm using PHP Tools for Visual Studio version 1.25.10474.2017 and Visual Studio Community 2017 version 15.5.2.

The incorrect formatting, unfortunately, makes PHP Tool unusable for me. I'm hoping there is a solution, because I'm otherwise thrilled to be able to write and debug php in Visual Studio.

Re: Problem formatting html when php code exists

PostPosted: January 25th, 2018, 10:27 am
by Miloslav Beno
Hi,

Thank you so much for a bug report.

We've been able to reproduce. We are going to fix this one.

Thanks again,

Re: Problem formatting html when php code exists

PostPosted: February 15th, 2018, 12:21 pm
by maros.beno
Hi,
thanks for reporting this. Fix will be available in the next update, which should be available as preview version today.