Skip to content

(twig) Indentation on wrapped lines is doubled #620

Open
@OldStarchy

Description

@OldStarchy

Example to reproduce on https://prettydiff.com/ (Beautify mode)

Before:

<html>
    <head></head>
    <body>
        <!-- 
            ALL SPACES AND NO TABS
            MAKES JACK A DULL BOY
        -->
        {#
            ALL SPACES AND NO TABS
            MAKES JACK A DULL BOY
        #}
        <p>
            ALL SPACES AND NO TABS
            MAKES JACK A DULL BOY
        </p>
        <div class="rows">
            <!-- 
                ALL SPACES AND NO TABS
                MAKES JACK A DULL BOY
            -->
            {#
                ALL SPACES AND NO TABS
                MAKES JACK A DULL BOY
            #}
            <p>
                ALL SPACES AND NO TABS
                MAKES JACK A DULL BOY
            </p>
            
            {# also note space introduced in the below div #}
            <div class="row date-row"></div>
            {% for person in data.people %}
                <div class="row">
                    <td class="name">{{ person.displayName }}</td>
                </div>
            {% endfor %}
        </div>
    </body>
</html>

After:

<html>
    <head></head>
    <body>
        <!--
            ALL SPACES AND NO TABS
                    MAKES JACK A DULL BOY -->
        {#
            	    ALL SPACES AND NO TABS
                    MAKES JACK A DULL BOY
            	#}
            <p>
        ALL SPACES AND NO TABS
                    MAKES JACK A DULL BOY
        </p>
            <div class="rows"> <!--
                    ALL SPACES AND NO TABS
                                MAKES JACK A DULL BOY -->
            {#
                    	    ALL SPACES AND NO TABS
                            MAKES JACK A DULL BOY
                    	#}
                <p>
            ALL SPACES AND NO TABS
                            MAKES JACK A DULL BOY
            </p>
            {# also note space introduced in the below div #}<div class="row date-row"> </div>
            {% for person in data.people %}
                <div class="row">
                    <td class="name">{{ person.displayName }}</td>
                </div>
            {% endfor %}
        </div>
    </body>
</html>

Formatting the output repetedly pushes the wrapped lines further and further right. Having combined with the format on save options, they run away to infinity (and beyond).

A couple issues have been raised about this in other repos.
mblode/vscode-twig-language#41
mblode/vscode-twig-language-2#50

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions