Moving and vanishing lines of code; trouble with Eclipse’s XML Editor

This bug is (finally) fixed in ADT 21. The fix is now available in ADT 21 Preview 9, posted a few minutes ago, here: https://android-review.googlesource.com/#/c/44936/1

The reason you get weird visual artifacts is that if a file contains broken DOS line endings (multiple carriage returns without a newline for each carriage return), Eclipse gets very confused. That’s Eclipse issue https://bugs.eclipse.org/bugs/show_bug.cgi?id=375421 .

There are two parts to the fix:
(1) First, ADT was fixed such that it no longer introduces these \r\r sequences into the document. This makes sure that you don’t get new documents which triggers the weird editing behavior, but it does not retroactively fix older documents with these line endings, so if you open them, you still get weird editing behavior.

(2) Second, there’s a new lint check which looks for broken line endings in documents. This runs incrementally, so if you edit an XML file which has this problem, ADT will add an error marker for this problem — along with a quickfix to perform surgery on the document to fix it.

In short:
Get ADT 21 Preview 9; run Lint on your projects and look for any complaints about files containing broken line endings, and if it finds any, apply the quickfix. From now on, further edits with the layout editor should keep the files consistently formatted.

FYI, the relevant fix is here: https://android-review.googlesource.com/#/c/44936/

Instructions for easily updating SDK Tools and the Eclipse ADT plugin are here: http://tools.android.com/preview-channel

— Tor
(from the Android tools team)

Leave a Comment