Redraw item if query string has changed

This commit is contained in:
Junegunn Choi 2017-02-24 02:30:11 +09:00
parent b29375c844
commit 0b940e4b2b
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -46,6 +46,7 @@ type itemLine struct {
current bool
selected bool
label string
queryLen int
width int
result Result
}
@ -737,11 +738,13 @@ func (t *Terminal) printItem(result *Result, line int, i int, current bool) {
}
// Avoid unnecessary redraw
newLine := itemLine{current: current, selected: selected, label: label, result: *result, width: 0}
newLine := itemLine{current: current, selected: selected, label: label,
result: *result, queryLen: len(t.input), width: 0}
prevLine := t.prevLines[i]
if prevLine.current == newLine.current &&
prevLine.selected == newLine.selected &&
prevLine.label == newLine.label &&
prevLine.queryLen == newLine.queryLen &&
prevLine.result == newLine.result {
return
}