From aa71a07fbe8fb3280f7661404a00d815f5b43a28 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 1 Jan 2023 21:16:09 +0900 Subject: [PATCH] Fix scrollbar rendering (#3096) --- src/terminal.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/terminal.go b/src/terminal.go index ec87593f..445a66ea 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -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, result: result, queryLen: len(t.input), width: 0, bar: bar} 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 && prevLine.selected == newLine.selected && prevLine.label == newLine.label && prevLine.queryLen == newLine.queryLen && prevLine.result == newLine.result { + printBar() return } @@ -1459,12 +1469,7 @@ func (t *Terminal) printItem(result Result, line int, i int, current bool, bar b if fillSpaces > 0 { t.window.Print(strings.Repeat(" ", fillSpaces)) } - 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) - } - } + printBar() t.prevLines[i] = newLine }