better fix for IDEA-184506

(cherry picked from commit f9ed8347772531c0008d5f1d1e9a5294ff0d821a)
This commit is contained in:
Vladimir Krivosheev
2019-03-23 17:31:59 +01:00
parent daa09d1183
commit ce8a9647c4
@@ -1,4 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.configurationStore
import com.intellij.util.containers.ObjectIntHashMap
@@ -57,9 +57,12 @@ internal class BinaryXmlWriter(private val out: DataOutputStream) {
out.writeByte(TypeMarker.CDATA.ordinal)
writeString(item.text)
}
is Text -> if (!isAllWhitespace(item)) {
out.writeByte(TypeMarker.TEXT.ordinal)
writeString(item.text)
is Text -> {
val text = item.text
if (text != null && !Verifier.isAllXMLWhitespace(text)) {
out.writeByte(TypeMarker.TEXT.ordinal)
writeString(text)
}
}
}
}
@@ -107,8 +110,4 @@ internal class BinaryXmlWriter(private val out: DataOutputStream) {
else -> throw IllegalArgumentException("Integer out of range: $v")
}
}
private fun isAllWhitespace(obj: Text): Boolean {
return obj.text?.all { Verifier.isXMLWhitespace(it) } ?: return true
}
}