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:
parent
4fc2c1e04c
commit
62ed920363
src/main/java/com/maddyhome/idea/vim
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user