mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-25 00:34:09 +02:00
Fix(VIM-2710): Show options value on set opt
This commit is contained in:
parent
da94edd386
commit
33d3f270a3
src
main/java/com/maddyhome/idea/vim/option
test/java/org/jetbrains/plugins/ideavim/ex/implementation/commands
vim-engine/src/main/kotlin/com/maddyhome/idea/vim
@ -34,13 +34,13 @@ import com.maddyhome.idea.vim.vimscript.services.IjVimOptionService
|
||||
*/
|
||||
object OptionsManager {
|
||||
val ignorecase: ToggleOption
|
||||
get() = (injector.optionService as IjVimOptionService).getRawOption(ignorecaseName) as ToggleOption
|
||||
get() = (injector.optionService as IjVimOptionService).getOptionByNameOrAbbr(ignorecaseName) as ToggleOption
|
||||
val smartcase: ToggleOption
|
||||
get() = (injector.optionService as IjVimOptionService).getRawOption(smartcaseName) as ToggleOption
|
||||
get() = (injector.optionService as IjVimOptionService).getOptionByNameOrAbbr(smartcaseName) as ToggleOption
|
||||
val timeout: ToggleOption
|
||||
get() = (injector.optionService as IjVimOptionService).getRawOption(timeoutName) as ToggleOption
|
||||
get() = (injector.optionService as IjVimOptionService).getOptionByNameOrAbbr(timeoutName) as ToggleOption
|
||||
val timeoutlen: NumberOption
|
||||
get() = (injector.optionService as IjVimOptionService).getRawOption(timeoutlenName) as NumberOption
|
||||
get() = (injector.optionService as IjVimOptionService).getOptionByNameOrAbbr(timeoutlenName) as NumberOption
|
||||
val iskeyword: KeywordOption
|
||||
get() = KeywordOption(KeywordOptionHelper)
|
||||
}
|
||||
|
@ -134,4 +134,18 @@ class SetCommandTest : VimTestCase() {
|
||||
typeText(commandToKeys("set selection?"))
|
||||
assertExOutput("selection=exclusive \n")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.OPTION)
|
||||
fun `test show numbered value`() {
|
||||
configureByText("\n")
|
||||
typeText(commandToKeys("set so"))
|
||||
assertExOutput("scrolloff=0 \n")
|
||||
}
|
||||
|
||||
@TestWithoutNeovim(reason = SkipNeovimReason.OPTION)
|
||||
fun `test show numbered value with questionmark`() {
|
||||
configureByText("\n")
|
||||
typeText(commandToKeys("set so?"))
|
||||
assertExOutput("scrolloff=0 \n")
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ abstract class VimOptionServiceBase : OptionService {
|
||||
options.get(optionName)!!.removeOptionChangeListener(listener)
|
||||
}
|
||||
|
||||
fun getRawOption(key: String): Option<out VimDataType>? {
|
||||
override fun getOptionByNameOrAbbr(key: String): Option<out VimDataType>? {
|
||||
return options.get(key)
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
|
||||
import com.maddyhome.idea.vim.ex.ExException
|
||||
import com.maddyhome.idea.vim.ex.ranges.Ranges
|
||||
import com.maddyhome.idea.vim.helper.Msg
|
||||
import com.maddyhome.idea.vim.option.ToggleOption
|
||||
import com.maddyhome.idea.vim.options.OptionScope
|
||||
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
|
||||
import java.util.*
|
||||
@ -133,12 +134,11 @@ fun parseOptionLine(editor: VimEditor, args: String, scope: OptionScope, failOnB
|
||||
}
|
||||
// No operator so only the option name was given
|
||||
if (eq == -1) {
|
||||
if (optionService.isToggleOption(token)) {
|
||||
optionService.setOption(scope, token, token)
|
||||
} else if (!optionService.getOptions().contains(token)) {
|
||||
error = Msg.unkopt
|
||||
} else {
|
||||
toShow.add(Pair(token, token))
|
||||
val option = optionService.getOptionByNameOrAbbr(token)
|
||||
when (option) {
|
||||
null -> error = Msg.unkopt
|
||||
is ToggleOption -> optionService.setOption(scope, token, token)
|
||||
else -> toShow.add(Pair(option.name, option.abbrev))
|
||||
}
|
||||
} else {
|
||||
// Make sure there is an option name
|
||||
@ -185,10 +185,10 @@ private fun showOptions(editor: VimEditor, nameAndToken: Collection<Pair<String,
|
||||
val optionService = injector.optionService
|
||||
val optionsToShow = mutableListOf<String>()
|
||||
var unknownOption: Pair<String, String>? = null
|
||||
val optionsAndAbbrevs = optionService.getOptions() + optionService.getAbbrevs()
|
||||
for (pair in nameAndToken) {
|
||||
if (optionsAndAbbrevs.contains(pair.first)) {
|
||||
optionsToShow.add(pair.first)
|
||||
val myOption = optionService.getOptionByNameOrAbbr(pair.first)
|
||||
if (myOption != null) {
|
||||
optionsToShow.add(myOption.name)
|
||||
} else {
|
||||
unknownOption = pair
|
||||
break
|
||||
|
@ -235,6 +235,11 @@ interface OptionService {
|
||||
*/
|
||||
fun removeListener(optionName: String, listener: OptionChangeListener<VimDataType>)
|
||||
|
||||
/**
|
||||
* Get the [Option] by its name or abbreviation
|
||||
*/
|
||||
fun getOptionByNameOrAbbr(key: String): Option<out VimDataType>?
|
||||
|
||||
/**
|
||||
* COMPATIBILITY-LAYER: Added this class
|
||||
* Please see: https://jb.gg/zo8n0r
|
||||
|
Loading…
Reference in New Issue
Block a user