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

Prompt redraw bugs out when editing with a multiline prompt with fzf #5945

Open
nhooyr opened this issue Jun 18, 2019 · 4 comments
Open

Prompt redraw bugs out when editing with a multiline prompt with fzf #5945

nhooyr opened this issue Jun 18, 2019 · 4 comments
Labels
bug Something that's not working as intended
Milestone

Comments

@nhooyr
Copy link
Contributor

nhooyr commented Jun 18, 2019

fish, version 3.0.2
Darwin ien.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
xterm-256color

Minimal config.fish:

function fish_prompt
    echo FIRST
    echo -n 'SECOND$ '
end

function fzf-bind-1
    fzf --height 40%
    commandline -t 1
    commandline -f repaint
end
bind \ea fzf-bind-1

function fzf-bind-2
    fzf --height 40%
    commandline -f repaint
end
bind \es fzf-bind-2

function fzf-bind-3
    commandline -t 1
    commandline -f repaint
end
bind \ed fzf-bind-3

function fzf-bind-4
    fzf --height 40%
end
bind \ef fzf-bind-4
  1. Move minimal config.fish into /tmp/home/.config/fish/config.fish
sh -c 'env HOME=/tmp/home fish'

Screen Shot 2019-06-18 at 4 26 42 PM

  1. Press alt+a to run fzf-bind-1. Exit fzf by pressing esc, you'll see the FIRST line of the prompt twice.

Screen Shot 2019-06-18 at 4 27 02 PM

  1. The second bind will show what happens when nothing is inserted, no additional FIRST line appears. The prompt looks normal.

  2. The third bind shows what happens when fzf isn't ran but 1 is inserted, no additional FIRST line appears.

Screen Shot 2019-06-18 at 4 27 40 PM

  1. The fourth bind shows what happens right after fzf runs. The SECOND line of the prompt is missing.

Screen Shot 2019-06-18 at 4 27 51 PM

Related: junegunn/fzf#1607

I believe its a fish bug and not an fzf bug due to other similar open issues like #5860 and that it only happens if you insert something into the commandline, repaint works normally without insertion.

@nhooyr
Copy link
Contributor Author

nhooyr commented Jun 18, 2019

Fifth binding:

function fzf-bind-5
    fzf --height 40%
    commandline -t 1
end
bind \eg fzf-bind-5

Shows what happens without commandline -f repaint.

Screen Shot 2019-06-18 at 4 39 41 PM

So the issue is reproducible by running just fzf followed by an commandline insertion.

@nhooyr nhooyr changed the title commandline bugs out when editing with a multiline prompt with fzf Prompt redraw bugs out when editing with a multiline prompt with fzf Nov 22, 2019
@zanchey zanchey added the bug Something that's not working as intended label Apr 29, 2020
@zanchey zanchey added this to the fish-future milestone Apr 29, 2020
@rouge8
Copy link
Contributor

rouge8 commented Dec 18, 2020

#5860 might be the cause of this. Adding printf '\033[J' to the start of my fish_prompt, as suggested in #5860 (comment), fixes the issue.

@zanchey
Copy link
Member

zanchey commented Dec 28, 2020

#5860 fixes the first issue, but not the fourth or fifth.

@mk12
Copy link
Contributor

mk12 commented Jan 4, 2022

It's still broken for me on fish 3.3.1. Every step (a to g) reproduces exactly as described by @nhooyr. Adding printf '\033[J' to the start of fish_prompt makes no difference for me. In that comment they say fish is drawing the prompt in the right place, but neglecting to clear the screen below. For me, it seems more that fish is just drawing the prompt in the wrong place, one line lower than it should.

I've found a different workaround, though. I just move the cursor up after invoking fzf:

function fzf-bind-1
    set result (fzf --height 40%)
    printf "\033[A"
    commandline -t 1
    commandline -f repaint
end
bind \ea fzf-bind-1

I'm also capturing the output of fzf to avoid printing it to the screen, allowing me to test that this works properly when you make a selection (i.e. press Enter instead of Escape).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that's not working as intended
Projects
None yet
Development

No branches or pull requests

4 participants