1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-02-26 14:46:00 +01:00

Compatibility of toggleOption

This commit is contained in:
Alex Plate 2022-07-05 10:56:45 +03:00
parent 51e7c745ea
commit 0da34bbb34
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
3 changed files with 17 additions and 3 deletions
vim-engine/src/main/kotlin/com/maddyhome/idea/vim

View File

@ -1,7 +1,9 @@
package com.maddyhome.idea.vim.option
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.options.Option
import com.maddyhome.idea.vim.options.OptionScope
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimInt
import com.maddyhome.idea.vim.vimscript.model.datatypes.parseNumber
@ -9,7 +11,8 @@ import com.maddyhome.idea.vim.vimscript.model.datatypes.parseNumber
/**
* COMPATIBILITY-LAYER: Moved out of class and to a different package
*/
open class NumberOption(name: String, abbrev: String, defaultValue: VimInt) : Option<VimInt>(name, abbrev, defaultValue) {
open class NumberOption(name: String, abbrev: String, defaultValue: VimInt) :
Option<VimInt>(name, abbrev, defaultValue) {
constructor(name: String, abbrev: String, defaultValue: Int) : this(name, abbrev, VimInt(defaultValue))
override fun checkIfValueValid(value: VimDataType, token: String) {
@ -32,4 +35,8 @@ open class NumberOption(name: String, abbrev: String, defaultValue: VimInt) : Op
val valueToAdd = parseNumber(token) ?: throw ExException("E521: Number required after =: $token")
return VimInt((currentValue as VimInt).value - valueToAdd)
}
fun value(): Int {
return injector.optionService.getOptionValue(OptionScope.GLOBAL, name).asDouble().toInt()
}
}

View File

@ -41,7 +41,7 @@ class ToggleOption(name: String, abbrev: String, defaultValue: VimInt) : Option<
/**
* COMPATIBILITY-LAYER: Method added
*/
fun getValue(): Boolean {
override fun getValue(): Boolean {
return injector.optionService.getOptionValue(OptionScope.GLOBAL, name).asBoolean()
}
}
}

View File

@ -57,6 +57,13 @@ import java.util.*
}
}
/**
* COMPATIBILITY-LAYER: Method added
*/
open fun getValue(): Boolean {
TODO()
}
// todo 1.9 should return Result with exceptions
abstract fun checkIfValueValid(value: VimDataType, token: String)