mirror of
https://github.com/junegunn/fzf.git
synced 2026-09-18 01:33:18 +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
|
width int
|
||||||
height int
|
height int
|
||||||
yoffset int
|
yoffset int
|
||||||
|
xoffset int
|
||||||
tabstop int
|
tabstop int
|
||||||
escDelay int
|
escDelay int
|
||||||
fullscreen bool
|
fullscreen bool
|
||||||
@@ -277,6 +278,7 @@ func (r *LightRenderer) Init() error {
|
|||||||
// increased and we're left with unwanted extra new line.
|
// increased and we're left with unwanted extra new line.
|
||||||
if x > 0 && r.clearOnExit {
|
if x > 0 && r.clearOnExit {
|
||||||
r.upOneLine = true
|
r.upOneLine = true
|
||||||
|
r.xoffset = x
|
||||||
r.makeSpace()
|
r.makeSpace()
|
||||||
}
|
}
|
||||||
// We assume that --no-clear is used for repetitive relaunching of fzf.
|
// We assume that --no-clear is used for repetitive relaunching of fzf.
|
||||||
@@ -1178,10 +1180,13 @@ func (r *LightRenderer) Close() {
|
|||||||
r.rmcup()
|
r.rmcup()
|
||||||
} else {
|
} else {
|
||||||
r.origin()
|
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 {
|
if r.upOneLine {
|
||||||
r.csi("A")
|
r.csi("A")
|
||||||
|
r.csi(fmt.Sprintf("%dG", r.xoffset+1))
|
||||||
}
|
}
|
||||||
r.csi("J")
|
|
||||||
}
|
}
|
||||||
} else if !r.fullscreen {
|
} else if !r.fullscreen {
|
||||||
r.stderr("\x1b8") // DECRC: restore cursor position
|
r.stderr("\x1b8") // DECRC: restore cursor position
|
||||||
|
|||||||
Reference in New Issue
Block a user