diff --git a/xml/tests/src/com/intellij/codeInsight/XmlTagTest.java b/xml/tests/src/com/intellij/codeInsight/XmlTagTest.java index 6736abbe4fe6..66be6b8a618a 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlTagTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlTagTest.java @@ -1017,4 +1017,18 @@ public class XmlTagTest extends LightCodeInsightTestCase { } }); } + + public void testSetAttributeValue() { + XmlFile file = (XmlFile)PsiFileFactory.getInstance(getProject()).createFileFromText("dummy.xml", XmlFileType.INSTANCE, "1", 0, true); + final XmlTag tag = file.getDocument().getRootTag(); + final Document document = file.getViewProvider().getDocument(); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + tag.setAttribute("attr", ""); + assertEquals("1", tag.getText()); + assertEquals("1", document.getText()); + } + }); + } } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java index 14beaf05ad89..a6343628cc3d 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java @@ -104,6 +104,7 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute, Hi } else { if (newValue != null) { + att.addChild(newValue.getTreePrev().copyElement()); att.addChild(newValue.copyElement()); } }