mirror of
https://github.com/junegunn/fzf.git
synced 2026-09-16 08:50:42 +08:00
Do not erase the line the prompt was on (#4918)
- 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:
+6
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user