redhat-developer / redhat-developer/vscode-xml

Formatter fails with unusual number of indentation spaces (1)

Open
#958 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug formatting
Dominant language
TypeScript
Stars
328
Forks
101
Avg merge
1d 17h
Merged PRs (30d)
7

Description

Or at least I think that's the issue - not sure if on extension's or VSCode's side.

I stumbled upon this file: https://github.com/WarmUpTill/SceneSwitcher/blob/master/forms/advanced-scene-switcher.ui which uses 1 space indentation.

I added my own code to it (QPushButton widget item):

                  <item>
                   <spacer name="horizontalSpacer_14">
                    <property name="orientation">
                     <enum>Qt::Horizontal</enum>
                    </property>
                    <property name="sizeHint" stdset="0">
                     <size>
                      <width>40</width>
                      <height>20</height>
                     </size>
                    </property>
                   </spacer>
                  </item>
                                    <item>
                                      <widget class="QPushButton" name="toggleElseActions">
                                        <property name="maximumSize">
                                          <size>
                                            <width>22</width>
                                            <height>16777215</height>
                                          </size>
                                        </property>
                                        <property name="flat">
                                          <bool>true</bool>
                                        </property>
                                        <property name="text">
                                          <string>!=</string>
                                        </property>
                                      </widget>
                                    </item>
                 </layout>

As you can see, the formatting is off, it decided to use 2 spaces instead of 1,

My VSCode settings are:

  • editor.detectIndentation set to true
  • editor.indentSize set to tabSize
  • editor.tabSize set to 4
  • editor.formatOnPaste set to true (but it also happens on file save or any other action that triggers formatter)

So no clue where 2 is coming from.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce formatting on forms/advanced-scene-switcher.ui using the reported VS Code settings, including format-on-paste and save. Inspect the extension's XML formatting entry point and how it detects indentation; done when the one-space indentation case has a verified, consistent outcome and a regression test or documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.