in vim-engine/src/main/kotlin/com/maddyhome/idea/vim/options/helpers/KeywordOptionHelper.kt [72:113]
fun parseValues(content: String): List<String>? {
if (!validationPattern.matcher(content).matches()) {
return null
}
var index = 0
var firstCharNumOfPart = true
var inRange = false
val vals: MutableList<String> = ArrayList()
var option = StringBuilder()
// We need to split the input string into parts. However, we can't just split on a comma
// since a comma can either be a keyword or a separator depending on its location in the string.
while (index <= content.length) {
var curChar = 0.toChar()
if (index < content.length) {
curChar = content[index]
}
index++
// If we either have a comma separator or are at the end of the content...
if (curChar == ',' && !firstCharNumOfPart && !inRange || index == content.length + 1) {
val part = option.toString()
vals.add(part)
option = StringBuilder()
inRange = false
firstCharNumOfPart = true
continue
}
option.append(curChar)
if (curChar == '^' && option.length == 1) {
firstCharNumOfPart = true
continue
}
if (curChar == '-' && !firstCharNumOfPart) {
inRange = true
continue
}
firstCharNumOfPart = false
inRange = false
}
return vals
}