mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-05-30 13:34:08 +02:00
Fix regression ignoring case in global command
Regression in new regex engine
This commit is contained in:
parent
79653b6048
commit
f1b94d7026
src/test/java/org/jetbrains/plugins/ideavim/ex/implementation/commands
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/model/commands
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user