1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-07-28 22:59:03 +02:00

Merge pull request from karavaevitalii/multiple-carets

Fixed bug with selecting occurrences when ignorecase is set
This commit is contained in:
Andrey Vlasovskikh 2018-08-27 21:55:06 +03:00 committed by GitHub
commit cc76c7f0f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions
src/com/maddyhome/idea/vim/extension/multiplecursors
test/org/jetbrains/plugins/ideavim/extension/multiplecursors

View File

@ -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) {

View File

@ -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)
}
}