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

Partial formating yields wrong intendation deep #1485

Closed
laeubi opened this issue Feb 17, 2023 · 14 comments · Fixed by #1486
Closed

Partial formating yields wrong intendation deep #1485

laeubi opened this issue Feb 17, 2023 · 14 comments · Fixed by #1486
Labels
bug Something isn't working formatting This issue or enhancement is related to formatting support
Milestone

Comments

@laeubi
Copy link
Contributor

laeubi commented Feb 17, 2023

If I format only a part of the document one gets wrong indentation, e.g.:

Current

image

Expected

image

@fbricon
Copy link
Contributor

fbricon commented Feb 17, 2023

Can you check in VS Code with https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml?

@angelozerr
Copy link
Contributor

@laeubi could you share your xml file please in order we can test with the same usecase than you.

@laeubi
Copy link
Contributor Author

laeubi commented Feb 17, 2023

  1. pom.xml.zip
  2. mark L 118 - 131
  3. press STRG+SHIFT+F
  4. You will see state from first screenshot
  5. press SHIFT+TAB two times to get expected result.

@fbricon
Copy link
Contributor

fbricon commented Feb 17, 2023

There's a bug somewhere in Lemminx, but not the one you see (which is most likely WWD specific):
Feb-17-2023 13-40-20

Section formatting leaks to the rest of the document for some reason (<type>eclipse-plugin</type> is messed up L138)

@fbricon
Copy link
Contributor

fbricon commented Feb 17, 2023

the issue seen in Eclipse might be LSP4E sending the wrong indentation character to lemminx

@laeubi
Copy link
Contributor Author

laeubi commented Feb 17, 2023

I trust you as the experts in this area to direct this to the right place, as a user I have no idea what all makes the difference here and can only guess it is related to Lemminx as the editr claims to be Lemminx based :-)

@angelozerr
Copy link
Contributor

@JessicaJHee could you see please the problem of @fbricon described in #1485 (comment) thanks

@angelozerr
Copy link
Contributor

@laeubi if you format the whole file in WWD and after you retry your usecase. Is it working better?

@laeubi
Copy link
Contributor Author

laeubi commented Feb 17, 2023

@angelozerr I'm not sure about WWD? I'm just using Eclipse with m2e, so if you download for example the last ibuild, create a new project and copy the file into it one should be able to reproduce (and probably see what/if other components are interfering here).

@angelozerr
Copy link
Contributor

angelozerr commented Feb 17, 2023

Sorry @laeubi, I'm too technical: WWD is the eclipse plugin which consumes lemminx: if you format the whole file in Eclipse IDE and after you retry your usecase. Is it working better?

@datho7561 datho7561 added this to the 0.25.0 milestone Feb 17, 2023
@datho7561 datho7561 added bug Something isn't working formatting This issue or enhancement is related to formatting support labels Feb 17, 2023
@datho7561 datho7561 reopened this Feb 17, 2023
@angelozerr
Copy link
Contributor

There's a bug somewhere in Lemminx, but not the one you see (which is most likely WWD specific):

@fbricon this problem has been fixed by @JessicaJHee with #1486

@angelozerr
Copy link
Contributor

angelozerr commented Feb 20, 2023

@laeubi the problem comes from WWD WWD which doesn't allow to configure spaces / tabs, see eclipse-wildwebdeveloper/wildwebdeveloper#872

Indeed, if you show spaces / tabs
image

you will notice that the indentation that you expect is spaces (and not tabs)

image

As WWD cannot configure the spaces / tabs for a given language like XML, it uses the default spaces / tabs

image

which uses tabs and not spaces. So when you format your select, the format uses tabs and not spaces. if you change to spaces

image

It should work, but all editor will use this configuration (ex : Java, etc).

It is not a trivial issue because it requires some changes to Eclipse Platform. I created a draft PR eclipse-platform/eclipse.platform.text#130

I close this issue since it is an issue of Eclipse Platform / WWD, please follow eclipse-wildwebdeveloper/wildwebdeveloper#872

@mickaelistria I think eclipse-platform/eclipse.platform.text#130
become important, we have more and more issues about spaces / tabs configuration capability.

@laeubi
Copy link
Contributor Author

laeubi commented Feb 20, 2023

@angelozerr thanks for the detailed analysis. I think for partial formatting, it would be great if lemminx would just use the existing style of the document, that most likely what a user will expect and desire.

@angelozerr
Copy link
Contributor

I had this idea, we could do that for formatting, but the main problem is if you are in tabs configuration (like you are), if you press tabs, it will generate a tab although your XML sample uses spaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working formatting This issue or enhancement is related to formatting support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants