1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-30 04:34:08 +02:00

Fix an issue that the XML config can't store nulls

This commit is contained in:
Alex Plate 2025-03-07 18:09:49 +02:00
parent 098243fb12
commit fc93661c62
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F

View File

@ -30,7 +30,7 @@ internal class VimState {
} }
stringMap.keys.forEach { name -> stringMap.keys.forEach { name ->
notifications?.getChild(name)?.getAttributeValue("value")?.let { notifications?.getChild(name)?.getAttributeValue("value")?.let {
stringMap[name] = it stringMap[name] = it.decode
} }
} }
} }
@ -46,12 +46,18 @@ internal class VimState {
} }
stringMap.forEach { (name, value) -> stringMap.forEach { (name, value) ->
val child = Element(name) val child = Element(name)
child.setAttribute("value", value) child.setAttribute("value", value.encode)
notifications.addContent(child) notifications.addContent(child)
} }
} }
} }
private val String?.encode: String get() = this ?: NULL_VALUE
private val String?.decode: String? get() = if (this == NULL_VALUE) null else this
// Settings cannot store null values
private const val NULL_VALUE = "__NULL_VALUE_CONST__"
private val map by lazy { mutableMapOf<String, Boolean>() } private val map by lazy { mutableMapOf<String, Boolean>() }
private val stringMap by lazy { mutableMapOf<String, String?>() } private val stringMap by lazy { mutableMapOf<String, String?>() }
@ -68,7 +74,8 @@ private class StateProperty(val xmlName: String) : ReadWriteProperty<VimState, B
} }
} }
private class StringProperty(val propertyName: String, val defaultValue: String?) : ReadWriteProperty<VimState, String?> { private class StringProperty(val propertyName: String, val defaultValue: String?) :
ReadWriteProperty<VimState, String?> {
init { init {
stringMap[propertyName] = defaultValue stringMap[propertyName] = defaultValue