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

Formatter breaks hexBinary by inserting newline and spaces #1010

Open
netmikey opened this issue Jun 14, 2024 · 6 comments
Open

Formatter breaks hexBinary by inserting newline and spaces #1010

netmikey opened this issue Jun 14, 2024 · 6 comments

Comments

@netmikey
Copy link

When we have an element containing long hexBinary data like this:

  <atr>6f1087c8105312e302e30820408a00005001588306312e3021000000a5049f1c611a4d02156501ff</atr>

The formatter modifies it to become:

  <atr>
    6f1087c8105312e302e30820408a00005001588306312e3021000000a5049f1c611a4d02156501ff</atr>

This however causes trouble down the line. Furthermore there's ultimately no real added benefit for breaking here since the resulting line cannot be further broken down and still doesn't fit into the maximum line length.

I didn't find an option to not break long single-word element content. I think such a configuration option should be considered and maybe even enabled by default.

@angelozerr
Copy link
Contributor

@netmikey
Copy link
Author

I've seen this setting and I'm confident it could be a workaround.

However, as far as I understand, this would also prevent all other content, like elements with regular, non-binary text content, to be formatted to fit the screen. Furthermore, the thought behind this report was more to have the formatter behave in a clever but conservative way by default so as to not cause trouble in its default configuration. I'd rather not rely on each developer editing XML files (probably on the fly without a dedicated workspace set up) that contain hexBinary elements to first go through the formatter configuration.

@angelozerr
Copy link
Contributor

You mean that you would like:

  • having max=0 when it is a long hexBinary data
  • using defined max for other text?

If it that I don't know how to do that,in XML Document long hexBinary data or text is considered as Text node.

@netmikey
Copy link
Author

I understand. Would it be an option to try detecting "long hexBinary lines (something along the lines of [0-9a-fA-F]{50,})" and changing the formatter's bahavior accordingly?

@angelozerr
Copy link
Contributor

angelozerr commented Jun 15, 2024

No there is no option for this usecase.

Do you know an xml formatter which does that?

@netmikey
Copy link
Author

We've checked a couple of other XML formatters in this regard:

  • Eclipse's seems to behave like this one does in its default config.
  • The XML Tools plugin in Notepad++ seems to behave as if max=0.

Inserting whitespace characters into hexBinary values like this by default caused us quite some trouble(shooting), so I thought it'd be nice if vscode-xml behaved better than other formatters by default, and since there are quite reliable ways to make it better I thought I'd give it a shot and open an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants