mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-02-26 05:46:00 +01:00
Compatibility of toggleOption
This commit is contained in:
parent
51e7c745ea
commit
0da34bbb34
vim-engine/src/main/kotlin/com/maddyhome/idea/vim
@ -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()
|
||||
}
|
||||
}
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user