summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-12-11 18:10:31 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-12-12 13:53:08 +0900
commitd30e37434eb28c456c1897c64a4e307137fda5dc (patch)
tree3f1ed5e92643da37a21fa6af1de34659f7037631 /src
parent20d5b2e20e2ac833e234f7e5bd85900848d41fb6 (diff)
downloadfzf-d30e37434eb28c456c1897c64a4e307137fda5dc.tar.gz
Less flickering of the candidate list when resizing the preview window
Diffstat (limited to 'src')
-rw-r--r--src/terminal.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 2ab67820..1b3efdec 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -2161,7 +2161,7 @@ func (t *Terminal) printItem(result Result, line int, maxLine int, index int, cu
}
maxWidth := t.window.Width() - (t.pointerLen + t.markerLen + 1)
- postTask := func(lineNum int, width int, wrapped bool) {
+ postTask := func(lineNum int, width int, wrapped bool, forceRedraw bool) {
if (current || selected) && t.highlightLine {
color := tui.ColSelected
if current {
@@ -2176,7 +2176,12 @@ func (t *Terminal) printItem(result Result, line int, maxLine int, index int, cu
}
newLine.width = maxWidth
} else {
- fillSpaces := t.prevLines[lineNum].width - width
+ var fillSpaces int
+ if forceRedraw {
+ fillSpaces = maxWidth - width
+ } else {
+ fillSpaces = t.prevLines[lineNum].width - width
+ }
if wrapped {
fillSpaces -= t.wrapSignWidth
}
@@ -2288,7 +2293,7 @@ func (t *Terminal) overflow(runes []rune, max int) bool {
return t.displayWidthWithLimit(runes, 0, max) > max
}
-func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMatch tui.ColorPair, current bool, match bool, lineNum int, maxLineNum int, forceRedraw bool, preTask func(markerClass), postTask func(int, int, bool)) int {
+func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMatch tui.ColorPair, current bool, match bool, lineNum int, maxLineNum int, forceRedraw bool, preTask func(markerClass), postTask func(int, int, bool, bool)) int {
var displayWidth int
item := result.item
matchOffsets := []Offset{}
@@ -2381,7 +2386,7 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
if t.layout == layoutDefault {
actualLineNum = (lineNum - actualLineOffset) + (numItemLines - actualLineOffset) - 1
}
- t.move(actualLineNum, 0, forceRedraw)
+ t.move(actualLineNum, 0, forceRedraw && postTask == nil)
if preTask != nil {
var marker markerClass
@@ -2485,7 +2490,7 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
t.printColoredString(t.window, line, offsets, colBase)
if postTask != nil {
- postTask(actualLineNum, displayWidth, wasWrapped)
+ postTask(actualLineNum, displayWidth, wasWrapped, forceRedraw)
} else {
t.markOtherLine(actualLineNum)
}