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

"Max attribute characters per line" is not respected even when "Attribute Tolerance"=5 and "Max attributes per line"=8 #450

Open
philipag opened this issue Nov 26, 2023 · 5 comments

Comments

@philipag
Copy link

philipag commented Nov 26, 2023

Describe the bug
The MACPL setting says that it will work with AT=5 and MAPL=8, but it has no effect. If I set MACPL=20, then the attributes do not wrap regardless of line length. Is MACPL fundamentally broken or am I doing something wrong?

To Reproduce
Steps to reproduce the behavior:
see above

Expected behavior
If I have 5 properties which make a line of 100 characters, I expect them to be split into separate lines such that each line contains either only 1 property or <= 20 characters.

Screenshots
image
image

External Configuration
NA

Version Info (please complete the following information):
Version 17.9.0 Preview 1.0, latest XAML Styler

@philipag philipag added the Bug label Nov 26, 2023
@grochocki
Copy link
Contributor

In this case, AT will take precedence. Until you cross AT threshold, MAPL and MACPL will have no effect.

Notes on MAPL:

Defines the maximum number of attributes an element can have on each line after the start tag if the number of attributes exceeds the Attribute Tolerance.

You can test this by creating an element with more than 5 attributes:

image

We do not support a hard column limit, nor do we believe it makes much sense to do so with a markup language like XAML given the many other supported ways of breaking up attributes across lines (#12).

@philipag
Copy link
Author

philipag commented Dec 14, 2023

@grochocki In my particular case with the 4 attributes that I have ( I cannot add a 5th attribute just to cause wrapping), how can I cause formatting to wrap while keeping up to 5 short attributes (on another element) on the same line?

I tried setting AT=2 and MAPL=8 but that seems to always wrap after 2 attributes no matter what...

What would make sense to me is that if MACPL is exceeded, then attributes will be removed from the line until either MACPL is not exceeded or only 1 attribute is left. I set MACPL to my screen width this would avoid having to constantly scroll my view (sometimes really far) in order to see all the attributes. It would at the same time allow me to have several attributes on the same line if they are short.

@ylyuanlei0110
Copy link

In this case, AT will take precedence. Until you cross AT threshold, MAPL and MACPL will have no effect.

Notes on MAPL:

Defines the maximum number of attributes an element can have on each line after the start tag if the number of attributes exceeds the Attribute Tolerance.

You can test this by creating an element with more than 5 attributes:

image

We do not support a hard column limit, nor do we believe it makes much sense to do so with a markup language like XAML given the many other supported ways of breaking up attributes across lines (#12).

image

How can I separate the two attributes in the first line.........

@philipag
Copy link
Author

@ylyuanlei0110 Thanks for the clear explanation. Unfortunately this means there is no way to prevent the line from going far past the screen width in my scenario (I don't want to decrease AT since that will mess up other formatting, and I cannot add properties just for the sake of breaking up the super long line). This results in poorly formatted lines when 1 property is very long due to complex bindings with converters and parameters, but there < AT other properties on the same line.

@ylyuanlei0110
Copy link

@ylyuanlei0110 Thanks for the clear explanation. Unfortunately this means there is no way to prevent the line from going far past the screen width in my scenario (I don't want to decrease AT since that will mess up other formatting, and I cannot add properties just for the sake of breaking up the super long line). This results in poorly formatted lines when 1 property is very long due to complex bindings with converters and parameters, but there < AT other properties on the same line.

Yeah, I'm confused for this problem recently. Seems no way to fix it with XamlStyler(⊙︿⊙)

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

No branches or pull requests

3 participants