pdt icon indicating copy to clipboard operation
pdt copied to clipboard

HTML template near to unreadable after save action format

Open collapsedev opened this issue 1 year ago • 4 comments

Describe the bug Format, on save actions, of HTML template near to unreadable

Describe the eclipse environment Eclipse PDT PDT Profiler UI Plug-in 8.0.0.202306050832 org.eclipse.php.profiler

Eclipse IDE for Java Developers (includes Incubating components) Version: 2023-03 (4.27.0) Build id: 20230309-1520 OS: Linux, *, x86_64 / gtk 3.24.38, WebKit 2.40.2 Java vendor: Eclipse Adoptium Java runtime version: 17.0.6+10 Java version: 17.0.6

To Reproduce Steps to reproduce the behavior:

  1. Create a template:


<html>
<head></head>
<body>
<p>
</p>
<?foreach (array('never','ever') as $i) :?>
 <?='I can not read this thing ' . $i?>
<?endforeach;?>
</body>
</html>

  1. Click on Source > Format


<html>
<head></head>
<body>
	<p></p>
<?foreach (array('never','ever') as $i) :?>
 <?='I can not read this thing ' . $i?>
<?endforeach;?>
</body>
</html>


  1. Enable: Window > Preferences > PHP > Editor > Save Actions > Format source code (Apply and close)
  2. Ctrl + S
  3. Result unreadable

<html>
<head></head>
<body>
	<p></p>
<?

foreach (array(
    'never',
    'ever'
) as $i) :
    ?>
 <?='I can not read this thing ' . $i?>
<?

endforeach
;
?>
</body>
</html>


Expected behavior Formatted as expected in step 3

collapsedev avatar Jun 09 '23 19:06 collapsedev

What about avoiding the short open php tag? I mean, try to use <?php instead of <?

mlocati avatar Jun 09 '23 20:06 mlocati

I think we need extra settings for short open tags, especially with alternate control structure syntaxes

zulus avatar Jun 12 '23 14:06 zulus

@zulus There have been several attempts to deprecate ASP-style tags and short-open-tags (even with its special control-structures):

  • https://wiki.php.net/rfc/remove_alternative_php_tags
  • https://wiki.php.net/rfc/deprecate_php_short_tags
  • did not find the deprecation RFC regarding the constrol-structures

I didn't read that far, but one (you? 🤔 ) should consider the current state.

brandung-sjorek avatar Jun 12 '23 14:06 brandung-sjorek

Not related to short tags, useful in my opinion. Related to something strange that occurs with "format source code" on save (Window > Preferences > PHP > Editor > Save Actions > Format source code). As you can see in step 3 after (Source > Format), code format is "normal". (Source > Format) code format different from (File > Save) with format source code enabled.

collapsedev avatar Jun 12 '23 15:06 collapsedev