diff --git a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/commands/GlobalCommandTest.kt b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/commands/GlobalCommandTest.kt index 84174c32c..c8989d5cd 100644 --- a/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/commands/GlobalCommandTest.kt +++ b/src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/commands/GlobalCommandTest.kt @@ -11,7 +11,6 @@ package org.jetbrains.plugins.ideavim.ex.implementation.commands import com.intellij.idea.TestFor import com.maddyhome.idea.vim.VimPlugin import com.maddyhome.idea.vim.history.HistoryConstants -import com.maddyhome.idea.vim.state.mode.Mode import org.jetbrains.plugins.ideavim.SkipNeovimReason import org.jetbrains.plugins.ideavim.TestWithoutNeovim import org.jetbrains.plugins.ideavim.VimTestCase @@ -204,6 +203,36 @@ class GlobalCommandTest : VimTestCase() { ) } + @Test + fun `test match ignores case`() { + doTest( + exCommand("g/test/p"), + """ + |one test + |two + |three Test + |four + |five TEST + """.trimMargin(), + """ + |one test + |two + |three Test + |four + |five TEST + """.trimMargin() + ) { + enterCommand("set ignorecase") + } + assertExOutput( + """ + |one test + |three Test + |five TEST + """.trimMargin() + ) + } + @Test fun `test check history`() { VimPlugin.getHistory().clear() @@ -335,6 +364,6 @@ end } private fun doTest(command: String, before: String, after: String) { - doTest(listOf(exCommand(command)), before, after, Mode.NORMAL()) + doTest(listOf(exCommand(command)), before, after) } } diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/model/commands/GlobalCommand.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/model/commands/GlobalCommand.kt index 06c6b2afa..8873bc7a0 100644 --- a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/model/commands/GlobalCommand.kt +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/model/commands/GlobalCommand.kt @@ -13,11 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext import com.maddyhome.idea.vim.api.VimEditor import com.maddyhome.idea.vim.api.VimRangeMarker import com.maddyhome.idea.vim.api.VimSearchGroupBase +import com.maddyhome.idea.vim.api.globalOptions import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.ex.ranges.LineRange import com.maddyhome.idea.vim.ex.ranges.Range +import com.maddyhome.idea.vim.helper.enumSetOf import com.maddyhome.idea.vim.regexp.VimRegexException +import com.maddyhome.idea.vim.regexp.VimRegexOptions import com.maddyhome.idea.vim.regexp.match.VimMatchResult import com.maddyhome.idea.vim.vimscript.model.ExecutionResult @@ -70,8 +73,12 @@ public data class GlobalCommand(val range: Range, val argument: String, val inve return false } + val options = enumSetOf<VimRegexOptions>() + if (injector.globalOptions().smartcase) options.add(VimRegexOptions.SMART_CASE) + if (injector.globalOptions().ignorecase) options.add(VimRegexOptions.IGNORE_CASE) + if (globalBusy) { - val match = regex.findInLine(editor, editor.currentCaret().getLine()) + val match = regex.findInLine(editor, editor.currentCaret().getLine(), 0, options) if (match is VimMatchResult.Success == !invert) { globalExecuteOne(editor, context, editor.getLineStartOffset(editor.currentCaret().getLine()), globalCommandArguments.command) } @@ -85,6 +92,7 @@ public data class GlobalCommand(val range: Range, val argument: String, val inve editor, editor.getLineStartOffset(line1), editor.getLineEndOffset(line2), + options, ) val matchesLines = matches.map { it.getLine(editor) }.toSet() val linesForGlobalCommand = if (invert) {