Permalink
Browse files

XECLIPSE-138: Automatically closed XML nodes have all attributes in the

closing tag

Applied patch. Thanks Alexey!
  • Loading branch information...
1 parent f24ae49 commit 95ccbf03ab9f69d128ef39489946a737a66149bb @jusio jusio committed with fmancinelli Nov 8, 2011
@@ -31,7 +31,7 @@
import org.xwiki.eclipse.ui.editors.Constants;
/**
- * @version $Id: 0272516d550290e2162bd74dfef93d659374aaef $
+ * @version $Id$
*/
public class XWikiMarkupAutoEditStrategy implements IAutoEditStrategy
{
@@ -124,15 +124,25 @@ private String getTag(IDocument document, char openingChar, int endOffset)
try {
int startOffset = endOffset;
int character;
-
+ int lastSpaceOffset = -1;
+
while (startOffset >= 0) {
character = document.getChar(startOffset);
+ if (character == ' ') {
+ lastSpaceOffset = startOffset;
+ }
if (character == '\n') {
return null;
}
if (character == openingChar) {
- return document.get(startOffset, endOffset - startOffset + 1);
+ int length;
+ if (lastSpaceOffset > 0) {
+ length = lastSpaceOffset - startOffset;
+ } else {
+ length = endOffset - startOffset + 1;
+ }
+ return document.get(startOffset, length);
}
startOffset--;

0 comments on commit 95ccbf0

Please sign in to comment.