in vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimSearchGroupBase.kt [451:479]
override fun findEndOfPattern(
command: String,
delimiter: Char,
startIndex: Int,
): Int {
var magic = true
var i = startIndex
while (i < command.length) {
// delimiter found
if (command[i] == delimiter) break
// collection start found, ignore until end of collection
if (magic && command[i] == '[' ||
!magic && command[i] == '\\' && i + 1 < command.length && command[i + 1] == '['
) {
i = findEndOfCollection(command, i)
// skip escaped char
} else if (command[i] == '\\' && i + 1 < command.length) {
i++
// update magic
if (command[i] == 'v' || command[i] == 'm') magic = true
if (command[i] == 'V' || command[i] == 'M') magic = false
}
i++
}
return i
}