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

Is it possible to prevent formatting of short lines - regardless of number of attributes? #430

Open
mrlacey opened this issue Jun 27, 2023 · 2 comments

Comments

@mrlacey
Copy link
Contributor

mrlacey commented Jun 27, 2023

Is your feature request related to a problem? Please describe.

I want greater control of formatting when all attributes can easily fit on a single line without compromising readability.

Describe the solution you'd like

I'd like an option to keep all attributes on a single line (regardless of how many attributes there are) when that line is less than a specified number of characters.

Both the elements defined below have the same number of attributes, I want them formatted like this, but I can't find a way to do it with the current options.

    <Label FontSize="32" Text="hello" TextDecorations="Underline" />

    <Label
        FontSize="32"
        Text="something much, much, much, much longer than simply 'hello'"
        TextDecorations="Underline" />

Having lots of short attributes on separate lines

I want a setting similar to Max attribute characters per line that will look at the total number of characters for the whole element if on a single line. If the number of characters is less than this threshold, everything will be put on a single line. If more than this, the other options will be used for formatting.

The nearest I can get with current options is

    <Label FontSize="32" Text="hello" TextDecorations="Underline" />

    <Label FontSize="32" Text="something much, much, much, much longer than simply 'hello'"
            TextDecorations="Underline" />

by using:
Attribute tolerance = 2
Keep first attribute on same line = true
Max Attribute characters per line = 80
Max attribute per line = 2

But what I want is a way to say: if everything is less than 80 chars, put it all on one line; otherwise, every attribute should be on a separate line.

Describe alternatives you've considered

I haven't found a suitable workaround other than applying all formatting manually.

Additional context

If this isn't already possible (in a way I haven't found), I'll happily implement it.

@grochocki
Copy link
Contributor

We've declined requests in the past for column break rules (#12), since while column break rules might work for most languages, we did not believe it made as much sense for a markup language like XAML that make use of heavy nested elements, but if this new setting was based on element length (and not line length), that starts to feel to me like a consistent alternative to Max Attribute Characters Per Line.

What are your thoughts on conflict resolution behavior between this new proposed setting and Max Attribute Characters Per Line?

@mrlacey
Copy link
Contributor Author

mrlacey commented Jul 18, 2023

What are your thoughts on conflict resolution behavior between this new proposed setting and Max Attribute Characters Per Line?

I would have this new setting take priority over MACPL as it considers the element as a whole, rather than just a subset. Actually, I would have this new setting override all (I think--but I haven't double-checked) other settings.
What I want from this option is the ability to say something equivalent to "in this specific situation, do this specific thing, but if this situation is not met, then follow the existing rules."
Having a new setting related to overall element length work in combination with other, existing settings would increase the complexity of the internal code as well as make it harder to reason over what results different combinations of settings will produce.
As a completely separate new setting, this also avoids any unexpected confusion and complication by possibly changing existing settings/behavior.

This new setting should default to a value of -1 and only be considered if greater than 0. (Yes, even though there's a theoretical minimal size of 13 before it could have a meaningful/useful effect.)

While I'm only proposing a single new setting that takes priority over all others, I recognize that this sets a precedent for potentially adding others in the future and that having multiple settings that each take priority over general settings introduces other challenges. I don't believe this should be a blocker, though, as there are ways of prioritizing multiple settings that may take priority, and these can be applied as and when this becomes a factor.

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

2 participants