1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-26 03:34:09 +02:00

Use null instead of -1 when the version of IdeaVim is not set

This commit is contained in:
Alex Plate 2025-02-03 11:05:17 +02:00
parent 4fc2c1e04c
commit 62ed920363
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
2 changed files with 8 additions and 11 deletions
src/main/java/com/maddyhome/idea/vim

View File

@ -19,11 +19,7 @@ internal class VimState {
var isIdeaJoinNotified by StateProperty("idea-join") var isIdeaJoinNotified by StateProperty("idea-join")
var isIdeaPutNotified by StateProperty("idea-put") var isIdeaPutNotified by StateProperty("idea-put")
var wasSubscribedToEAPAutomatically by StateProperty("was-automatically-subscribed-to-eap") var wasSubscribedToEAPAutomatically by StateProperty("was-automatically-subscribed-to-eap")
var firstIdeaVimVersion: String? by StringProperty("first-ideavim-version", null)
/**
* First logged version of IdeaVim, or "-1" if no version logged
*/
var firstIdeaVimVersion: String by StringProperty("first-ideavim-version", "-1")
fun readData(element: Element) { fun readData(element: Element) {
val notifications = element.getChild("notifications") val notifications = element.getChild("notifications")
@ -57,7 +53,7 @@ internal class VimState {
} }
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?>() }
private class StateProperty(val xmlName: String) : ReadWriteProperty<VimState, Boolean> { private class StateProperty(val xmlName: String) : ReadWriteProperty<VimState, Boolean> {
@ -72,16 +68,17 @@ 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
} }
override fun getValue(thisRef: VimState, property: KProperty<*>): String = override fun getValue(thisRef: VimState, property: KProperty<*>): String? {
stringMap.getOrPut(propertyName) { defaultValue } return stringMap.getOrPut(propertyName) { defaultValue }
}
override fun setValue(thisRef: VimState, property: KProperty<*>, value: String) { override fun setValue(thisRef: VimState, property: KProperty<*>, value: String?) {
stringMap[propertyName] = value stringMap[propertyName] = value
} }
} }

View File

@ -24,7 +24,7 @@ internal class IjVimEnabler : VimEnabler {
fun ideOpened() { fun ideOpened() {
val myFirstVersion = VimPlugin.getVimState().firstIdeaVimVersion val myFirstVersion = VimPlugin.getVimState().firstIdeaVimVersion
if (myFirstVersion == "-1") { if (myFirstVersion == null) {
VimPlugin.getVimState().firstIdeaVimVersion = VimPlugin.getVersion() VimPlugin.getVimState().firstIdeaVimVersion = VimPlugin.getVersion()
this.isNewUser = true this.isNewUser = true
} }