Skip to content

Commit

Permalink
Less flickering of the candidate list when resizing the preview window
Browse files Browse the repository at this point in the history
  • Loading branch information
junegunn committed Dec 12, 2024
1 parent 20d5b2e commit d30e374
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down Expand Up @@ -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{}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit d30e374

Please sign in to comment.