mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-07-28 22:59:03 +02:00
Merge pull request #156 from karavaevitalii/multiple-carets
Fixed bug with selecting occurrences when ignorecase is set
This commit is contained in:
commit
cc76c7f0f3
src/com/maddyhome/idea/vim/extension/multiplecursors
test/org/jetbrains/plugins/ideavim/extension/multiplecursors
@ -18,6 +18,7 @@ import com.maddyhome.idea.vim.helper.CaretData
|
||||
import com.maddyhome.idea.vim.helper.EditorHelper
|
||||
import com.maddyhome.idea.vim.helper.SearchHelper.findWordUnderCursor
|
||||
import com.maddyhome.idea.vim.helper.StringHelper.parseKeys
|
||||
import com.maddyhome.idea.vim.option.Options
|
||||
import java.lang.Integer.min
|
||||
|
||||
private const val NEXT_WHOLE_OCCURRENCE = "<Plug>NextWholeOccurrence"
|
||||
@ -69,7 +70,7 @@ class VimMultipleCursorsExtension : VimNonDisposableExtension() {
|
||||
val patterns = sortedSetOf<String>()
|
||||
for (caret in caretModel.allCarets) {
|
||||
val selectedText = caret.selectedText ?: return
|
||||
patterns += selectedText
|
||||
patterns += if (Options.getInstance().isSet("ignorecase")) selectedText.toLowerCase() else selectedText
|
||||
|
||||
val lines = selectedText.count { it == '\n' }
|
||||
if (lines > 0) {
|
||||
|
@ -258,6 +258,7 @@ class VimMultipleCursorsExtensionTest : VimTestCase() {
|
||||
""".trimMargin()
|
||||
myFixture.checkResult(after)
|
||||
}
|
||||
|
||||
fun testRemoveOccurrence() {
|
||||
val before = """private i<caret>nt a = 0;
|
||||
|private int b = 1;
|
||||
@ -444,4 +445,33 @@ class VimMultipleCursorsExtensionTest : VimTestCase() {
|
||||
myFixture.checkResult(after)
|
||||
}
|
||||
|
||||
fun testNextOccurrenceIgnorecase() {
|
||||
val before = """fun getCellType(<caret>pos: VisualPosition): CellType {
|
||||
if (pos in snakeCells) {
|
||||
return CellType.SNAKE
|
||||
}
|
||||
val char = getCharAt(pos)
|
||||
return when {
|
||||
char.isWhitespace() || pos in eatenCells -> CellType.EMPTY
|
||||
char in ANTI_PYTHON_CHARS -> CellType.FOOD
|
||||
else -> CellType.WALL
|
||||
}
|
||||
}"""
|
||||
configureByText(before)
|
||||
|
||||
typeText(commandToKeys("set ignorecase"))
|
||||
typeText(parseKeys("g<A-n><A-n><A-n>"))
|
||||
val after = """fun getCellType(<selection>pos</selection>: Visual<selection>Pos</selection>ition): CellType {
|
||||
if (<selection>pos</selection> in snakeCells) {
|
||||
return CellType.SNAKE
|
||||
}
|
||||
val char = getCharAt(pos)
|
||||
return when {
|
||||
char.isWhitespace() || pos in eatenCells -> CellType.EMPTY
|
||||
char in ANTI_PYTHON_CHARS -> CellType.FOOD
|
||||
else -> CellType.WALL
|
||||
}
|
||||
}"""
|
||||
myFixture.checkResult(after)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user