diff --git a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/GetCmdTypeFunctionTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/GetCmdTypeFunctionTest.kt new file mode 100644 index 0000000000..9886f91a41 --- /dev/null +++ b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/functions/GetCmdTypeFunctionTest.kt @@ -0,0 +1,51 @@ +/* + * Copyright 2003-2024 The IdeaVim authors + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE.txt file or at + * https://opensource.org/licenses/MIT. + */ + +package org.jetbrains.plugins.ideavim.ex.implementation.functions + +import com.maddyhome.idea.vim.api.injector +import com.maddyhome.idea.vim.ui.ex.ExEntryPanel +import org.jetbrains.plugins.ideavim.VimTestCase +import org.junit.jupiter.api.Test +import kotlin.test.assertEquals + +class GetCmdTypeFunctionTest : VimTestCase() { + + @Test + fun `test getcmdtype() for a regular command`() { + configureByText("\n") + enterCommand("cmap z getcmdtype()") + typeText(":fooz") + assertEquals("foo:", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText) + } + + @Test + fun `test getcmdtype() for a forward search`() { + configureByText("\n") + enterCommand("cmap z getcmdtype()") + typeText("/fooz") + assertEquals("foo/", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText) + } + + @Test + fun `test getcmdtype() for a backward search`() { + configureByText("\n") + enterCommand("cmap z getcmdtype()") + typeText("?fooz") + assertEquals("foo?", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText) + } + + @Test + fun `test getcmdtype() for an expression command`() { + configureByText("\n") + enterCommand("cmap z getcmdtype()") + typeText("i=fooz") + assertEquals("foo=", (injector.commandLine.getActiveCommandLine() as ExEntryPanel).visibleText) + } + +} \ No newline at end of file diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/model/functions/handlers/GetCmdTypeFunctionHandler.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/model/functions/handlers/GetCmdTypeFunctionHandler.kt index 09faa7c615..d6ec77a937 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/model/functions/handlers/GetCmdTypeFunctionHandler.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/model/functions/handlers/GetCmdTypeFunctionHandler.kt @@ -22,7 +22,6 @@ import com.maddyhome.idea.vim.vimscript.model.functions.FunctionHandler /* Return the current command-line type. Possible return values are: : normal Ex command - > debug mode command debug-mode / forward search command ? backward search command = i_CTRL-R_= @@ -30,6 +29,7 @@ Return the current command-line type. Possible return values are: Returns an empty string otherwise. Not yet implemented: + > debug mode command debug-mode @ input() command - :insert or :append command */