ui5-language-assistant icon indicating copy to clipboard operation
ui5-language-assistant copied to clipboard

VSCode indents most lines with spaces but some in tabs

Open swayongshen opened this issue 2 years ago • 3 comments

Currently using UI5 language assistant as default formatter for .xml files with these VSCode settings enabled.

{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnPaste": true,
  "editor.formatOnType": false, // required
  "editor.formatOnSave": true, // optional
  "editor.formatOnSaveMode": "file", // required to format on save
  "files.autoSave": "onFocusChange", // optional but recommended
  "editor.insertSpaces": true,
  "editor.tabSize": 2,
  "[xml]": {
    "editor.defaultFormatter": "SAPOSS.vscode-ui5-language-assistant",
    "editor.detectIndentation": false
  },
  "files.associations": {
    "*.xml": "xml"
  }
}

These are the prettier settings

{
  "printWidth": 80,
  "tabWidth": 2,
  "useTabs": false,
  "semi": true,
  "singleQuote": true,
  "trailingComma": "es5",
  "bracketSpacing": true,
  "arrowParens": "always",
  "proseWrap": "never",
  "htmlWhitespaceSensitivity": "strict",
  "endOfLine": "lf"
}

The format result is that for most lines, spaces are used for indentation but it seems for lines of objects in quotes e.g. 'core:require' and 'items', tabs are used.

<mvc:View
    controllerName="sap.vi.results.controller.Main"
    displayBlock="true"
    xmlns="sap.m"
    xmlns:mvc="sap.ui.core.mvc"
    xmlns:core="sap.ui.core"
    xmlns:table="sap.ui.table"
    core:require="{
		formatter: 'sap/vi/results/model/formatter'
	}"
>
    <!-- Temporary table to view mock data -->
    <Table
        id="table"
        inset="false"
        items="{
			path: '/InspectionResults',
			sorter: {
				path: 'id'
			}
		}"
    >
...

swayongshen avatar Oct 04 '23 02:10 swayongshen

@swayongshen Thanks for your feedback. Currently UI5 language assistant does not format objects which are represented as strings in xml attribute so they are taken over without formatting. We can think of an enhancement to support objects in xml strings in future

BTW: are you aware of any formatter in xml which also formats strings representing objects in xml attribute?

MN-public avatar Oct 04 '23 08:10 MN-public

@MN-public

Thank you for your response, I am not aware of any such formatters.

swayongshen avatar Oct 11 '23 04:10 swayongshen

BTW: are you aware of any formatter in xml which also formats strings representing objects in xml attribute?

Not sure about the name, but the now deprecated SAP Web IDE used a formatter that would also format object string within XML

BenReim avatar Oct 11 '23 06:10 BenReim