Fix scrollbar rendering (#3096)

This commit is contained in:
Junegunn Choi 2023-01-01 21:16:09 +09:00
parent 088293f5e7
commit aa71a07fbe
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -1421,11 +1421,21 @@ func (t *Terminal) printItem(result Result, line int, i int, current bool, bar b
newLine := itemLine{current: current, selected: selected, label: label, newLine := itemLine{current: current, selected: selected, label: label,
result: result, queryLen: len(t.input), width: 0, bar: bar} result: result, queryLen: len(t.input), width: 0, bar: bar}
prevLine := t.prevLines[i] prevLine := t.prevLines[i]
printBar := func() {
if len(t.scrollbar) > 0 && bar != prevLine.bar {
t.move(line, t.window.Width()-1, true)
if bar {
t.window.CPrint(tui.ColScrollbar, t.scrollbar)
}
}
}
if prevLine.current == newLine.current && if prevLine.current == newLine.current &&
prevLine.selected == newLine.selected && prevLine.selected == newLine.selected &&
prevLine.label == newLine.label && prevLine.label == newLine.label &&
prevLine.queryLen == newLine.queryLen && prevLine.queryLen == newLine.queryLen &&
prevLine.result == newLine.result { prevLine.result == newLine.result {
printBar()
return return
} }
@ -1459,12 +1469,7 @@ func (t *Terminal) printItem(result Result, line int, i int, current bool, bar b
if fillSpaces > 0 { if fillSpaces > 0 {
t.window.Print(strings.Repeat(" ", fillSpaces)) t.window.Print(strings.Repeat(" ", fillSpaces))
} }
if len(t.scrollbar) > 0 && bar != prevLine.bar { printBar()
t.move(line, t.window.Width()-1, true)
if bar {
t.window.CPrint(tui.ColScrollbar, t.scrollbar)
}
}
t.prevLines[i] = newLine t.prevLines[i] = newLine
} }