Do not erase the line the prompt was on (#4918)
CodeQL / Analyze (go) (push) Canceled after 0s
build / build (push) Canceled after 0s
Test fzf on macOS / build (push) Canceled after 0s

- When the cursor is not at column 0, Init() makes space so fzf draws on
  the next line and the prompt line is left intact
- Close() undid that: it moved up onto the prompt line before ESC[J, so
  the erase wiped a line fzf never wrote on
- Shells repaint afterwards, so it showed as a flicker of the last prompt
  line. Reported on fish, also seen on bash and nushell. zsh erases the
  same line but repaints fast enough to hide it
- Erase our own area first, then step back and restore the column, so
  nothing on that line is touched, RPROMPT included

Fix #4913
This commit is contained in:
Junegunn Choi
2026-09-10 23:19:38 +09:00
committed by GitHub
parent 1578b7c3c3
commit b224480a98
+6 -1
View File
@@ -175,6 +175,7 @@ type LightRenderer struct {
width int
height int
yoffset int
xoffset int
tabstop int
escDelay int
fullscreen bool
@@ -277,6 +278,7 @@ func (r *LightRenderer) Init() error {
// increased and we're left with unwanted extra new line.
if x > 0 && r.clearOnExit {
r.upOneLine = true
r.xoffset = x
r.makeSpace()
}
// We assume that --no-clear is used for repetitive relaunching of fzf.
@@ -1178,10 +1180,13 @@ func (r *LightRenderer) Close() {
r.rmcup()
} else {
r.origin()
// Erase our own area first, then step back onto the line the
// prompt was on, so nothing on that line is touched
r.csi("J")
if r.upOneLine {
r.csi("A")
r.csi(fmt.Sprintf("%dG", r.xoffset+1))
}
r.csi("J")
}
} else if !r.fullscreen {
r.stderr("\x1b8") // DECRC: restore cursor position