aemide / issue-tracker

0 stars 0 forks source link

Bug: Occasional incorrect indentation of XML when sync'd from CRX w/o formatting #1

Open HitmanInWis opened 1 month ago

HitmanInWis commented 1 month ago

I am configured to NOT reformat files after Content Sync, but I AM configured to clean up invalid fields. I believe the clean up function is what's bugged to leave invalid indentation.

An example is as follows:

<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:dam="http://www.day.com/dam/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="nt:file">
    <jcr:content
        jcr:lastModifiedBy="admin"
        jcr:mixinTypes="[dam:Thumbnails]"
        jcr:primaryType="nt:resource"/>
</jcr:root>

becomes

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:dam="http://www.day.com/dam/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="nt:file">
    <jcr:content
            jcr:mixinTypes="[dam:Thumbnails]"
        jcr:primaryType="nt:resource"/>
</jcr:root>
karollewandowski commented 1 month ago

Hi Brett, This one is problematic to change. Deleting junk attributes is done with IntelliJ Platform API, and it formats the surroundings according to the project XML formatter configuration: Settings | Editor | Code Style | XML | Tabs and Indents | Continuation indent.

I think it is uncommon to use inconsistent formatting for files of the same type across the project. I suggest changing the mentioned formatter option to 4 and using it consistently in all files. Another option is to select the Reformat content files option you mentioned.

HitmanInWis commented 1 month ago

Interesting - this probably means that it only happens if the item removed is the first attribute of the XML element (making the next item now the first element).

I'm trying to avoid the "reformat content files" option b/c it means that everyone on the project has to be using IntelliJ to have XML format the exact same, which the FE Devs often do not.

That said, I see little harm in making the continuation indent for XML files 4 instead of 8, and it does indeed avoid the issue.

HitmanInWis commented 1 month ago

Well actually, the functionality seems to be inconsistent...when I pull a full folder from CRX I'm still seeing this strange indent on some files, but then if I sync that file again it goes away. Almost like there's some sort of race condition going on.

HitmanInWis commented 1 month ago

And now it seems fine - I'll report back if I see the issue any more, but for now the workaround (making the continuation indent for XML files 4 instead of 8) is working for me.

karollewandowski commented 1 month ago

Well actually, the functionality seems to be inconsistent...when I pull a full folder from CRX I'm still seeing this strange indent on some files, but then if I sync that file again it goes away. Almost like there's some sort of race condition going on.

Now I'm worried. I'll monitor it.