Open CodeAnthem opened 3 years ago
Can you show a before and after example of what you are looking to achieve here?
Before: (this is what I try to archieve)
<RowDefinition Height="50" /> <!-- Title -->
<RowDefinition Height="*" /> <!-- Main Content -->
After:
<RowDefinition Height="50" />
<!-- Title -->
<RowDefinition Height="*" />
<!-- Main Content -->
Thanks alot
Oops!
Get Outlook for iOShttps://aka.ms/o0ukef
From: averon420 notifications@github.com Sent: Monday, February 22, 2021 2:24:41 PM To: Xavalon/XamlStyler XamlStyler@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: Re: [Xavalon/XamlStyler] Keep comment on same line (#328)
Before:
After:
Thanks alot
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FXavalon%2FXamlStyler%2Fissues%2F328%23issuecomment-783411244&data=04%7C01%7C%7Cdfb2a9374b3344c56b3708d8d73d9810%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637496006822839703%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=yfQf0fPJLJT9pFBDoSZaUfKZmpSb985q7F4NhjYgwjw%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAB45RMY6J3XTMDQT4AUSXN3TAJSKTANCNFSM4X4PNUGQ&data=04%7C01%7C%7Cdfb2a9374b3344c56b3708d8d73d9810%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637496006822849660%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=vJLmCSzmMwgIk1AXc%2BFcbVcSgeOPWJVYFWynkC7nh2M%3D&reserved=0.
I agree, but I'd like to extend this request, so that an option is provided to have any comment left in situ, not just after Row and ColumnDefinitions. Very often I want a comment to be after a XAML declaration but on the same line so it more obviously explains the purpose of the XAML.
Here's an example of what I want, before applying "Format XAML":
<Brush x:Key="Theme.Background">#FF5D6B99</Brush> <!-- This is the Main Background color for the Theme -->
. . . . . . and this is what I now get after applying "Format XAML":
<Brush x:Key="Theme.Background">#FF5D6B99</Brush>
<!-- This is the Main Background color for the Theme -->
Because I use comments on the same line quite extensively, my XAML can get quite ugly and unreadable after formatting with XAML Styler.
I think this could be achieved relatively easily, by specifying an optional first character in the XAML comment that doesn't typically appear as the first character of a string comment (eg another "<") . The presence of that first character indicates the comment should be exempt from normal styling (in other words left wherever it was put); absence of that special first character means the comment is subject to normal styling rules and placed on the next line, as is the current default. Hence the following line would result in no change after applying "Format XAML":
<Brush x:Key="Theme.Background">#FF5D6B99</Brush> <!-- <This is the Main Background color for the Theme -->
I would also like to keep comments on the same line. Mostly for Row/Column definition comments though. So it would be great with an option for those at least.
I understand the use case better now, and I agree with @sojatay that this would be better implemented as a broader setting around preserving comment location, though I am not a fan of adding non-standard/special characters:
I think this could be achieved relatively easily, by specifying an optional first character in the XAML comment that doesn't typically appear as the first character of a string comment (eg another "<") . The presence of that first character indicates the comment should be exempt from normal styling (in other words left wherever it was put); absence of that special first character means the comment is subject to normal styling rules and placed on the next line, as is the current default.
Maybe it can be done without the special character by keeping track of whether the comment originates on its own line?
Yes, that would be better than having to use some special character. Thanks for a great tool btw.
@grochocki . What you have suggested is much better than the unnecessarily complicated "solution" I proposed.
Maybe you could check if the comment start tag is preceded only by white space on the line it appears in - in which case it should be subject to formatting by XAML Styler. If there are characters other than white space on the comment's line, it should stay on that line.
...or maybe even......just give an option to "Exclude Comments from Styler Formatting" ?? It's slightly cruder, but would enable comments to be left wherever the developer wrote them.
Overall the tool is fantastic for me - and this small limitation is the only minor niggle I have with it. Thank you for it.
I really like this extension, your doing a great job at it. Having the comments automatically placed on a new line is bugging me. If there could just be a "keep comments on same line" option would be great.
So that before apply XAML styler:
<ColumnDefinition Width="50" /><!--Name Column-->
<ColumnDefinition Width="70" /><!--Date Column-->
This is what after XAML styler currently does (unwanted):
<ColumnDefinition Width="50" />
<!-- Name Column -->
<ColumnDefinition Width="70" />
<!-- Date Column -->
and this is what I prefer, after apply XAML styler:
<ColumnDefinition Width="50" /><!--Name Column-->
<ColumnDefinition Width="70" /><!--Date Column-->
Has there been any progress on this? This feature request is 18 months old now. It seems to be a popular enhancement, and the position of trailing comments after applying XAML styler still bugs me a lot.
I'd do it myself in a fork if I believed I was competent to do so. I'm not!
I just discovered this tool and I think it's great! But I would also like this feature. In my case, most of my inline comments are after RowDefinition
and ColumnDefinition
. Personally, I also like to line up those comments vertically (with some padding):
<RowDefinition Height="Auto"> <!-- Title -->
<RowDefinition Height="*"> <!-- Content -->
Hello, I'd like to have my comments for ColumnDefinition and RowDefinition on same line, is there any option to do that? Or could one be implemented?
Thanks :)