in vim-engine/src/main/kotlin/com/maddyhome/idea/vim/key/ShortcutOwner.kt [23:68]
fun toNotation(): String {
val owners = HashMap<ShortcutOwner, MutableList<String>>()
owners[normal] = (owners[normal] ?: mutableListOf()).also { it.add("n") }
owners[insert] = (owners[insert] ?: mutableListOf()).also { it.add("i") }
owners[visual] = (owners[visual] ?: mutableListOf()).also { it.add("x") }
owners[select] = (owners[select] ?: mutableListOf()).also { it.add("s") }
if ("x" in (owners[ShortcutOwner.VIM] ?: emptyList()) && "s" in (owners[ShortcutOwner.VIM] ?: emptyList())) {
val existing = owners[ShortcutOwner.VIM] ?: mutableListOf()
existing.remove("x")
existing.remove("s")
existing.add("v")
owners[ShortcutOwner.VIM] = existing
}
if ("x" in (owners[ShortcutOwner.IDE] ?: emptyList()) && "s" in (owners[ShortcutOwner.IDE] ?: emptyList())) {
val existing = owners[ShortcutOwner.IDE] ?: mutableListOf()
existing.remove("x")
existing.remove("s")
existing.add("v")
owners[ShortcutOwner.IDE] = existing
}
if ((owners[ShortcutOwner.IDE] ?: emptyList()).isEmpty()) {
owners.remove(ShortcutOwner.VIM)
owners[ShortcutOwner.VIM] = mutableListOf("a")
}
if ((owners[ShortcutOwner.VIM] ?: emptyList()).isEmpty()) {
owners.remove(ShortcutOwner.IDE)
owners[ShortcutOwner.IDE] = mutableListOf("a")
}
val ideOwners = (owners[ShortcutOwner.IDE] ?: emptyList()).sortedBy { wights[it] ?: 1000 }.joinToString(separator = "-")
val vimOwners = (owners[ShortcutOwner.VIM] ?: emptyList()).sortedBy { wights[it] ?: 1000 }.joinToString(separator = "-")
return if (ideOwners.isNotEmpty() && vimOwners.isNotEmpty()) {
ideOwners + ":" + ShortcutOwner.IDE.ownerName + " " + vimOwners + ":" + ShortcutOwner.VIM.ownerName
} else if (ideOwners.isNotEmpty() && vimOwners.isEmpty()) {
ideOwners + ":" + ShortcutOwner.IDE.ownerName
} else if (ideOwners.isEmpty() && vimOwners.isNotEmpty()) {
vimOwners + ":" + ShortcutOwner.VIM.ownerName
} else {
error("Unexpected state")
}
}