From ce036b544a307cbc20f6d92f9d1e28ad12e66e30 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 27 May 2014 16:28:31 +0400 Subject: [PATCH] IDEA-125129 I would like to reopen IDEA-117698: regression fixed --- .../editorActions/XmlSlashTypedHandler.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlSlashTypedHandler.java b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlSlashTypedHandler.java index 051a75044e74..a389ef215dd0 100644 --- a/xml/impl/src/com/intellij/codeInsight/editorActions/XmlSlashTypedHandler.java +++ b/xml/impl/src/com/intellij/codeInsight/editorActions/XmlSlashTypedHandler.java @@ -29,6 +29,7 @@ import com.intellij.psi.templateLanguages.OuterLanguageElement; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.*; +import com.intellij.xml.util.XmlTagUtil; import com.intellij.xml.util.XmlUtil; import org.jetbrains.annotations.NotNull; @@ -91,13 +92,13 @@ public class XmlSlashTypedHandler extends TypedHandlerDelegate implements XmlTok if (element1 != null && element1.getText().startsWith(" tag.getTextOffset()) { + if (shouldReplace(tag, tag1)) { tag = tag1; } else { // if we have enclosing jsp tag, actual tag to be completed will be previous sibling tag1 = PsiTreeUtil.getPrevSiblingOfType(element1.getParent(), XmlTag.class); - if (tag1 != null && tag1 != tag && tag1.getTextOffset() > tag.getTextOffset()) { + if (shouldReplace(tag, tag1)) { tag = tag1; } } @@ -135,4 +136,9 @@ public class XmlSlashTypedHandler extends TypedHandlerDelegate implements XmlTok } return Result.CONTINUE; } + + public boolean shouldReplace(XmlTag tag, XmlTag tag1) { + return tag1 != null && tag1 != tag && tag1.getTextOffset() > tag.getTextOffset() && + XmlUtil.getTokenOfType(tag1, XmlTokenType.XML_EMPTY_ELEMENT_END) == null && XmlTagUtil.getEndTagNameElement(tag1) == null; + } } \ No newline at end of file