Smart Indent: Vertical alignment of attributes

Are you missing a feature? Request its implementation here.
pgfearo
Posts: 7
Joined: Wed Mar 20, 2013 9:12 pm

Smart Indent: Vertical alignment of attributes

Post by pgfearo »

For XSLT editing, especially when long XPath expressions are used, it would be helpful if smart indentation worked for attributes as well as elements as in the following screenshot:

Image

Currently, each time I copy and paste code (internally or from other XSLT files) or reformat existing code, the indentation of attributes is lost.
adrian
Posts: 2883
Joined: Tue May 17, 2005 4:01 pm

Re: Smart Indent: Vertical alignment of attributes

Post by adrian »

Hello,

Are you referring to the indentation of the select attribute (from the variable currentIsClosed), its multi line value or both ?

Currently, Oxygen indents everything (elements/attributes) with the detected indent size.
However, if you don't want the pasted code to be automatically indented by Oxygen, there's an option you can disable: Options > Preferences, Editor / Format / XML, Indent on paste ... (last option).
Note that if you manually Format and Indent the document/code, Oxygen will use its formatting/indenting options and break the vertical attribute alignment.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
pgfearo
Posts: 7
Joined: Wed Mar 20, 2013 9:12 pm

Re: Smart Indent: Vertical alignment of attributes

Post by pgfearo »

> Are you referring to the indentation of the select attribute (from the variable currentIsClosed), its multi line value or both ?

Naturally, I'm referring to all the attribute-related indentation - so both the select attribute and its multi-line value.

> Currently, Oxygen indents everything (elements/attributes) with the detected indent size.

Yes, but the way it indents attributes is not helpful because previously aligned attributes lose their alignment. Thus, if I copy-and-paste or reformat the containing xsl:variable element neither the attribute name or its multi-line value is indented so that things remain aligned - as you go on to say...

> Note that if you manually Format and Indent the document/code, Oxygen will use its formatting/indenting options and break the vertical attribute alignment.

Agreed. Hence this feature request - I would like Oxygen to preserve vertical attribute alignment (please!).

Without this feature, editing XSLT with long XPath expressions is a chore - and probably causes XSLT developers to either compromise on the way they code their XPath/XSLT or use another editor (which would proabably be a bad thing either way).
adrian
Posts: 2883
Joined: Tue May 17, 2005 4:01 pm

Re: Smart Indent: Vertical alignment of attributes

Post by adrian »

Hi,

To clarify, you want:
- the attribute name from the new line to be vertically aligned to the first attribute name from the previous line.
- each new line from the multi line attribute value to be vertically aligned to the beginning of the attribute value.

There is still an issue here when the formatter has to insert or remove a line break in front of an attribute.
e.g.
If the formatter has a maximum line width of 55:

Code: Select all

 <xsl:variable name="token" select="$tokens[$index]"
as="element()?"/>
<=>
If the formatter has a maximum line width of 80:

Code: Select all

<xsl:variable name="token" select="$tokens[$index]" as="element()?"/>
The attribute as will be moved up/down when formatting depending if it fits within the width of the first line. Do you consider acceptable this attribute movement (it can go both ways depending on the available width and the attribute+value length)?

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
pgfearo
Posts: 7
Joined: Wed Mar 20, 2013 9:12 pm

Re: Smart Indent: Vertical alignment of attributes

Post by pgfearo »

> To clarify, you want:
> - the attribute name from the new line to be vertically aligned to the first attribute name from
> the previous line.
> - each new line from the multi line attribute value to be vertically aligned to the beginning of the
> attribute value.

Yes. Thanks for breaking this into rules - I was being lazy relying on the graphic to illustrate the point. It would be great if Oxygen could do this.

> The attribute as will be moved up/down when formatting depending if it fits within the width of the first line. Do you consider acceptable this attribute movement (it can go both ways depending on the available width and the attribute+value length)?

Opinion may vary on this. My own view is that it is ok to add a line-break before the attribute name if it would otherwise exceed the max line length, but removing a line-break before an attribute to fill available space on the previous line would not be desirable (for example, I often like to have a select attribute on a new line as it is quite likely I will need to add to it in a later edit).

One other rule:
- If the first attribute of an element is preceded by a line-break it should have the same amount of indentation as if it were a child element or text, for example:

Code: Select all

<xsl:apply-templates
select="$tokens[$index]/abc/def/thedocument[@title = 'long title name']"/>
I think Oxygen behaves like this currently which is fine - the alternative of vertically aligning the attribute to the end of the element name on the previous line would not normally be a good thing.
adrian
Posts: 2883
Joined: Tue May 17, 2005 4:01 pm

Re: Smart Indent: Vertical alignment of attributes

Post by adrian »

Thank you for clarifying.

I've submitted a feature request to our issue tracking tool for adding an option for this type of formatting and indenting. I've mentioned the rules proposed here and your comments.
This will be analyzed and if found appropriate, it will be implemented in a future version of Oxygen. We will post a notification on this thread when this feature is implemented.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply