Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fzf erases scrollback buffer on Windows #1766

Open
7 of 10 tasks
wjrogers opened this issue Nov 21, 2019 · 11 comments
Open
7 of 10 tasks

fzf erases scrollback buffer on Windows #1766

wjrogers opened this issue Nov 21, 2019 · 11 comments
Labels

Comments

@wjrogers
Copy link

  • I have read through the manual page (man fzf)
  • I have the latest version of fzf
  • I have searched through the existing issues

Info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Shell
    • cmd
    • powershell
    • pwsh (PowerShell Core)

Problem / Steps to reproduce

  1. Open a new Command Prompt
  2. Generate some terminal buffer content with e.g. dir or tree
  3. Run fzf
  4. Hit ESC to exit
  5. Observe the terminal buffer has been erased and the scrollback cleared

Interestingly, in the new Windows Terminal, the problem is less severe: only the visible lines in the terminal are erased when running fzf. Anything in the scrollback buffer is still there afterward.

@LuRsT
Copy link

LuRsT commented Feb 22, 2020

Hi @wjrogers, if you set the --height option, you can make fzf smaller, which should at least erase fewer lines. Also, if you use the option --reverse, it opens below the prompt, which may completely solve your issue.

@wjrogers
Copy link
Author

@LuRsT I am using --reverse, and passing --height gives the message "--height option is currently not supported on Windows"

@KindDragon
Copy link

@wjrogers PR #1341 should fix this

@wjrogers
Copy link
Author

I just tested in 0.24.1, and this bug is not fixed. Will you please re-open? (@KindDragon's comment was referring to the --height option, which is now supported on Windows.)

@junegunn junegunn reopened this Oct 30, 2020
@junegunn
Copy link
Owner

So this problem only happens when you don't use --height option?

@wjrogers
Copy link
Author

Correct. Using --height works around it because it scrolls the terminal far enough for the fzf "window" to fit below the prompt.

@junegunn
Copy link
Owner

junegunn commented Oct 30, 2020

Can you test if this binary helps in your case? I don't have a Windows environment to test it now.

It just makes fzf use the new renderer instead of tcell library when it's available.

diff --git a/src/terminal.go b/src/terminal.go
index 778665a..8697d21 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -408,11 +408,11 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
 	var renderer tui.Renderer
 	fullscreen := opts.Height.size == 0 || opts.Height.percent && opts.Height.size == 100
 	if fullscreen {
-		if tui.HasFullscreenRenderer() {
-			renderer = tui.NewFullscreenRenderer(opts.Theme, opts.Black, opts.Mouse)
-		} else {
+		if tui.IsLightRendererSupported() {
 			renderer = tui.NewLightRenderer(opts.Theme, opts.Black, opts.Mouse, opts.Tabstop, opts.ClearOnExit,
 				true, func(h int) int { return h })
+		} else {
+			renderer = tui.NewFullscreenRenderer(opts.Theme, opts.Black, opts.Mouse)
 		}
 	} else {
 		maxHeightFunc := func(termHeight int) int {

@wjrogers
Copy link
Author

Yes, that binary completely fixes the bug! Tested both Command Prompt and Windows Terminal. Windows 20H2 (19042.610).

@junegunn
Copy link
Owner

Thanks for the confirmation. Patch pushed to master. Please report any issues you run into.

/cc @kelleyma49

@junegunn junegunn reopened this Oct 30, 2020
@junegunn
Copy link
Owner

junegunn commented Oct 30, 2020

I had to revert the commit as it doesn't work correctly inside Vim.

junegunn/fzf.vim#1152 (comment)

kralicky pushed a commit to kralicky/fzf that referenced this issue Jun 23, 2021
@vovcacik
Copy link
Contributor

The tcell library used in FullscreenRenderer is clipping the console's buffer to the size of console's window during initialization (and few more occasions). There was an effort to preserve the buffer and restore it on exit gdamore/tcell#288.

You could also switch to LightRenderer with fzf --height=99%.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants