in vim-engine/src/main/kotlin/com/maddyhome/idea/vim/api/VimCommandLine.kt [128:176]
fun selectHistory(isUp: Boolean, filter: Boolean) {
val history = injector.historyGroup.getEntries(historyType, 0, 0)
val dir = if (isUp) -1 else 1
if (histIndex + dir < 0 || histIndex + dir > history.size) {
injector.messages.indicateError()
return
}
if (filter) {
var i: Int = histIndex + dir
while (i >= 0 && i <= history.size) {
var txt: String?
if (i == history.size) {
txt = lastEntry
} else {
val entry: HistoryEntry = history[i]
txt = entry.entry
}
val myLastEntry = lastEntry
if (txt != null && myLastEntry != null && txt.startsWith(myLastEntry)) {
setText(txt, updateLastEntry = false)
caret.offset = txt.length
histIndex = i
return
}
i += dir
}
injector.messages.indicateError()
} else {
histIndex += dir
val txt: String?
if (histIndex == history.size) {
txt = lastEntry
} else {
val entry: HistoryEntry = history[histIndex]
txt = entry.entry
}
if (txt != null) {
setText(txt, updateLastEntry = false)
caret.offset = txt.length
}
}
}