OSDN Git Service
Fix and turn on the auto-format XML option
This changeset turns on the option to "Automatically format the XML
edited by the visual layout editor" by default.
It also fixes several issues related to it:
- First, the auto-format code was previously hooked up to synchronous
insert and delete node events, which meant during a larger edit it
would apply formatting repeatedly and before the edit was complete
(which made the DOM model keep reparsing to update document based
back into its internal model).
- Another problem was that the auto format only applied to added and
removed nodes; attribute edits were not considered (which made sense
given that the old formatter did not support reordering of
attributes, but now that it does attribute changes requires
reformatting as well.)
- The old reformatter was trying to work with the Eclipse XML
formatter, which does not handle partial document formats well
(there were a bunch of workarounds, and even with those there were
some problems). The new formatter does not, so I've changed the
option to be tied to the custom formatter; the automatic formatting
of layout editor changes is now enabled only when the custom editor
is enabled.
This also takes advantage of the new formatter's ability to only
format the attributes section of a document, so if you just tweak
the attribute of a node, the children's formatting is not affected.
- The formatter would apply to more than just the layout editor; any
UI editor which used UiElementNodes would be affected. I've added a
method, by default false, where each UI editor can opt into this.
I'd like to get Raphael's feedback on the manifest editor before
possibly adding it for that editor as well (and updating the option
name to something more generic).
- The mechanism for ignoring XML document changes (already used for
refactoring) is now also connected to reformatting, so when the
formatter runs it sets an "ignore" flag such that there is no
second XML model loading when the changes are just as a result
of a formatting option.
This changeset also tweaks the formatting behavior of comments;
instead of -always- adding a blank line before line comments (other
than suffix comments), it now considers the previous document and
preserves the spacing used there (though it will collapse multiple
lines into one).
Change-Id: I04c2b80836c4d9874dca789c2f2cbc8c8c7cfa76