Html code window fail rendering with php code inside

Not always … sometimes … I did not understand under what conditions…

Code editor display an corrupted source-code, there are trucated from after doctype tag to first occurence of an php script tag.

See following my real code:

My original code:

<?php
//require_once ('security_access.inc.php');
require_once ('security_access_anonym.inc.php');
?>
<!doctype html>
<html lang="it" data-pgc-master="SecMaster.php">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
...
  <hr class="pt-2 pb-2 "/>
            <div class="container-fluid w-75 mt-3">
                <div class="alert alert-danger <?=empty ($_SESSION['parameters']['message']) ? "d-none" : "";?>">
                    <strong><?=!empty($_SESSION['parameters']['message']) ? "Attenzione!" : "";?></strong>&nbsp;
                   <?=!empty($_SESSION['parameters']['message']) ? $_SESSION['parameters']['message'] : "";?>
                </div>
                <form role="form" action="security_login.php" method="post" class="was-validated">
                    <div class="form-group">

Resulting damaged code in window code editor from start of file:

<!doctype: "";
<php: "";</php>
                </div>
                <form role="form" action="security_login.php" method="post" class="was-validated" target="_pg_blank" data-pg-id="407">
                    <div class="form-group" data-pg-id="408">
...followed by rest of file...

Note that if I save the file, page are not corrupted and reopen it is intact.

I’m using: PG 4.8 on Linux Mint LMDE 2 Cinnamon 64-bit, Apache2, PHP 5.6.36