Sublime Forum

Php Syntax, html in if else reindent problem

#1

why does it align end to end. it wasn’t like this in sublime text 3. i just switched to st4. this is annoying

0 Likes

#2

Does it happen in SAFE MODE?

I can’t reproduce it on my ST 4168 on Win 11, neither in normal setup nor when running ST in SAFE MODE with

<?php if ($xx->durum == '1'): ?>
	<span class="foo bar baz">Ack</span>
<?php elseif ($xx->durum == '2'): ?>
	<span class="foo bar baz">Ack</span>
<?php elseif ($xx->durum == '-1'): ?>
	<span class="foo bar baz">Ack</span>
<?php else: ?>
	<span class="foo bar baz">Ack</span>
<?php endif ?>

Also an indentation test exists to verify that’s not happening. It’s also passing.


An issue I found is line 9 <?php endif ?> not being unindented due to missing newline at the end.

The closest I can create to achieve something as described by OP is by unclosed <span> tags.

<? if (true): ?>
	<span>
<? elseif (false) : ?>
	<span>
<? endif ?>

… which becomes …

<? if (true): ?>
	<span>
	<? elseif (false) : ?>
		<span>
		<? endif ?>

… due to indentation rules of HTML applying after <span>.

But that’s something which I guess can barely be fixed without completely removing indentation rules for HTML within PHP files.

1 Like

#3

the solution for me was the htmlUnderScore plugin.
I checked my previous st3 one by one. and it was fixed when I installed this plugin.

0 Likes

#4

HTML Underscore Syntax package overrides built-in HTML syntax and its indentation rules.

It assignes itself to text.html.basic scope. I wouldn’t be surprised it to cause other unwanted side-effects, now that many packages rely on and extend built-in HTML syntax.

1 Like