Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange formatting in new line #163

Open
PrinceOfAbyss opened this issue Jan 8, 2025 · 1 comment
Open

Strange formatting in new line #163

PrinceOfAbyss opened this issue Jan 8, 2025 · 1 comment

Comments

@PrinceOfAbyss
Copy link

I don't know how to describe the situation. So let me give you an example... So suppose this code extract:

        <?php if ( isset( $_GET['tax'] ) ) {
        global $wpdb;

        $terms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woo_filters_mapping WHERE tax_slug = '%s';", sanitize_text_field( $_GET['tax'] ) ) ); ?>
		<div id="menu-management" style="margin-top: 2em;">
			<form id="terms-mapping" method="post" enctype="multipart/form-data">

			</form>
		</div>
        <?php }?>

Please notice the difference in the tab kind: 4 spaces for the PHP code and 1 literal tab for HTML code

So, when I format the document, it becomes like this:

        <?php if ( isset( $_GET['tax'] ) ) {
        global $wpdb;

        $terms = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woo_filters_mapping WHERE tax_slug = '%s';", sanitize_text_field( $_GET['tax'] ) ) ); ?>
		<div id="menu-management" style="margin-top: 2em;">
			<form id="terms-mapping" method="post" enctype="multipart/form-data">

			</form>
		</div>
        <?php
}?>

For some reason the closing of the PHP block, along with the closing bracket of the if() statement move to a new line.

@driade
Copy link

driade commented Jan 9, 2025

Yes, unfortunatelly the formatter does not prefectly work when mixing PHP and HTML. It's a known bug hard to fix, I'll try to take a look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants