History log of /sdk/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/AndroidXmlAutoEditStrategyTest.java
Revision Date Author Comments
45fa942e9b5c773c72b703194bc0470e991a4a0f 29-Nov-2011 Tor Norbye <tnorbye@google.com> Fix auto-indent for text nodes after closing tag (issue #22332)

This changeset fixes the auto-indent handling for a specific scenario:
pressing newline within a text node, when the next non-text region is
an element end tag, and the caret is not on the same line as the end
tag. This scenario is covered by the new unit tests testIssue22332a
and testIssue22332b.

Change-Id: I238423ddf25864746a941d6ac8c1fb6a41e37601
743da746af54b31c1bfca2e3f7ec639d0b93251d 19-Aug-2011 Tor Norbye <tnorbye@google.com> Make smart indent handle whitespace indentation better

The smart indent implementation handles indenting within element
content (e.g. between tag names and attributes) and at element
boundaries (e.g. before and after <>'s.) For other parts of the
document it just defaulted to the normal XML smart indent.

However, this includes handling newlines within blank space. This
changeset adds special handling for some key scenarios:

Indent the newly inserted line depending on the surrounding context:

<foo> <foo>
| ====>
</foo> |
</foo>

Also subtract whitespace on the right hand side of the cursor when
necessary:

<foo> <foo>
| <bar/> ====>
</foo> |</bar>
</foo>

There are some other cases as well, described in the unit tests.

Change-Id: I8e679800fe56cae598f430b6f6de409309407708
83d04640bf245bb9ce108cef01e188761bc905f8 02-Aug-2011 Tor Norbye <tnorbye@google.com> Improve smart-indent handling in XML files

This changeset adds a new "auto edit strategy" for Android XML files,
which replaces the default XML auto-indenter (which just copied the
indentation of the previous line.)

The new indenter instead uses the lexical information to indent based
on the tag and bracket balance.

For example, if the | represents the caret position, then the
following shows how the edits are transformed:

<foo name="value"/>| => <foo name="value"/>
|

<foo name="value">| => <foo name="value">
|

<foo <foo
attr1 = "value1"|> => attr1 = "value1"
|>

<foo <foo
attr1 = "value1"/>| => attr1 = "value1"/>
|

It can also modify the text after the caret, as in the following
transformation:

<foo>|</foo> => <foo>
|
</foo>

See the unit test for more cases.

Change-Id: Ia99ecf6573ff4a9473970aa2fd481d2228ddf45d