IDEA-112914 Insert closing tag after typing </ : fixing tests

This commit is contained in:
Dmitry Avdeev
2013-09-02 13:15:03 +04:00
parent 601f184ac7
commit c28ebf2080
2 changed files with 7 additions and 1 deletions
@@ -85,7 +85,7 @@ public class XmlSlashTypedHandler extends TypedHandlerDelegate implements XmlTok
final String prevLeafText = prevLeaf.getText();
if ("</".equals(prevLeafText) && prevLeaf.getElementType() == XML_END_TAG_START) {
XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
if (tag != null && StringUtil.isNotEmpty(tag.getName())) {
if (tag != null && StringUtil.isNotEmpty(tag.getName()) && TreeUtil.findSibling(prevLeaf, XmlTokenType.XML_NAME) == null) {
EditorModificationUtil.insertStringAtCaret(editor, tag.getName() + ">");
return Result.STOP;
}
@@ -29,4 +29,10 @@ public class XmlTypedHandlersTest extends LightPlatformCodeInsightFixtureTestCas
myFixture.type('/');
myFixture.checkResult("<foo></foo>");
}
public void testGreedyClosing() {
myFixture.configureByText(XmlFileType.INSTANCE, "<foo><<caret>foo>");
myFixture.type('/');
myFixture.checkResult("<foo></foo>");
}
}