1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-03-03 18:32:54 +01:00

Added a colon after scope for variables in VimScriptGlobalEnvironment

This commit is contained in:
lippfi 2021-09-27 15:19:39 +03:00
parent 0bc298014d
commit a480372d3d
2 changed files with 11 additions and 1 deletions
src/com/maddyhome/idea/vim/vimscript/services
test/org/jetbrains/plugins/ideavim/ex/implementation/commands

View File

@ -61,7 +61,8 @@ object VariableService {
when (scope) {
Scope.GLOBAL_VARIABLE -> {
globalVariables[variable.name] = value
VimScriptGlobalEnvironment.getInstance().variables[(variable.scope?.c ?: "") + variable.name] = value.simplify()
val scopeForGlobalEnvironment = if (variable.scope != null) variable.scope.c + ":" else ""
VimScriptGlobalEnvironment.getInstance().variables[scopeForGlobalEnvironment + variable.name] = value.simplify()
}
Scope.SCRIPT_VARIABLE -> {
val scriptName = vimContext.getScriptName()

View File

@ -18,6 +18,7 @@
package org.jetbrains.plugins.ideavim.ex.implementation.commands
import com.maddyhome.idea.vim.ex.vimscript.VimScriptGlobalEnvironment
import com.maddyhome.idea.vim.option.OptionsManager
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
@ -145,4 +146,12 @@ class LetCommandTest : VimTestCase() {
typeText(commandToKeys("echo s"))
assertExOutput("[1, 2, 3]\n")
}
fun `test vimScriptGlobalEnvironment`() {
configureByText("\n")
typeText(commandToKeys("let g:WhichKey_ShowVimActions = \"true\""))
typeText(commandToKeys("echo g:WhichKey_ShowVimActions"))
assertExOutput("true\n")
assertEquals("true", VimScriptGlobalEnvironment.getInstance().variables["g:WhichKey_ShowVimActions"])
}
}