PatrickF1 / fzf.fish

🔍🐟 Fzf plugin for Fish
MIT License
1.96k stars 78 forks source link

Weird "O" and "I" characters are inserted in the search bar when changing tmux panes #285

Closed rudenkornk closed 1 year ago

rudenkornk commented 1 year ago

Before proceeding...

Describe the bug

When running in tmux and changing panes, weird "O" and "I" characters are inserted in the search bar. image

This issue is also described here: https://github.com/fish-shell/fish-shell/issues/6942 And its possible solution is described in this comment: https://github.com/fish-shell/fish-shell/issues/6942#issuecomment-984758528 Applying this to the fzf_configure_bindings.fish it can be fixed with this patch (I am too lazy for the PR):

33,38c33,38
<             test -n $key_sequences[1] && bind --mode $mode $key_sequences[1] _fzf_search_directory
<             test -n $key_sequences[2] && bind --mode $mode $key_sequences[2] _fzf_search_git_log
<             test -n $key_sequences[3] && bind --mode $mode $key_sequences[3] _fzf_search_git_status
<             test -n $key_sequences[4] && bind --mode $mode $key_sequences[4] _fzf_search_history
<             test -n $key_sequences[5] && bind --mode $mode $key_sequences[5] _fzf_search_processes
<             test -n $key_sequences[6] && bind --mode $mode $key_sequences[6] "$_fzf_search_vars_command"
---
>             test -n $key_sequences[1] && bind --mode $mode $key_sequences[1] __fish_disable_focus _fzf_search_directory
>             test -n $key_sequences[2] && bind --mode $mode $key_sequences[2] __fish_disable_focus _fzf_search_git_log
>             test -n $key_sequences[3] && bind --mode $mode $key_sequences[3] __fish_disable_focus _fzf_search_git_status
>             test -n $key_sequences[4] && bind --mode $mode $key_sequences[4] __fish_disable_focus _fzf_search_history
>             test -n $key_sequences[5] && bind --mode $mode $key_sequences[5] __fish_disable_focus _fzf_search_processes
>             test -n $key_sequences[6] && bind --mode $mode $key_sequences[6] __fish_disable_focus "$_fzf_search_vars_command"

Steps to reproduce

Run tmux, go to any git repo, open any fzf.fish finder and change pane focus.

Versions installed:

Which, if any, configuration variables such as fzf_preview_file_cmd are set?

set --export FZF_DEFAULT_OPTS \
  --ansi \
  --bind ctrl-u:half-page-up,ctrl-d:half-page-down,ctrl-b:preview-page-up,ctrl-f:preview-page-down \
  --border \
  --cycle \
  --height=90% \
  --layout=reverse \
  --marker="*" \
  --multi \
  --preview-window=wrap \

set --export fzf_fd_opts \
    --exclude .ansible \
    --exclude .cache \
    --exclude .cargo \
    --exclude .config \
    --exclude .dbus \
    --exclude .fzf \
    --exclude .git \
    --exclude .gnupg \
    --exclude .gradle \
    --exclude .local \
    --exclude .npm\
    --exclude .rustup \
    --exclude .tmux \
    --follow \
    --hidden \
    --type file \
PatrickF1 commented 1 year ago

What is __fish_disable_focus?

rudenkornk commented 1 year ago

I do not know actually. I guess it somehow manages focus events in fish

PatrickF1 commented 1 year ago

Can you try that solution and validate that it works? I don't use Tmux and don't have the bandwidth to learn Tmux. Also, I searched everywhere and still can't find what __fish_disable_focus is and it certainly isn't a function on my fish env.

rudenkornk commented 1 year ago

I did try it and it works perfectly for me. In fact, I am just patching fzf.fish when deploying my dotfiles: Ansible task, which patches fzf.fish: https://github.com/rudenkornk/dotfiles/blob/0521fc39a86a16c36ccc1a27e9e5d644c4555758/roles/shell_utils/tasks/main.yaml#L101 The patch itself (it also includes new mode, similar to search directory, but with ripgrep): https://github.com/rudenkornk/dotfiles/blob/0521fc39a86a16c36ccc1a27e9e5d644c4555758/roles/shell_utils/files/fzf.fish.patch

PatrickF1 commented 1 year ago

Ok, I'm glad you automated this! Unfortunately, I've decided not to fix this. I think if I had more bandwidth or I was a Tmux user, I would definitely do it. But I don't have the bandwidth to add it and maintain it, especially as someone who doesn't use Tmux. I did find the source of __fish_disable_focus (https://github.com/fish-shell/fish-shell/blob/master/share/functions/__fish_config_interactive.fish#L220) but it's a really bad signal for the maintainability because it's underscored, meaning we're not supposed to be using it.

okobenoko commented 1 year ago

The same problem was encountered when switching workspaces using hyprland

Drowze commented 11 months ago

Also facing the same issue. I've long ignored it but it's indeed very annoying 😕

Would love to see this change going upstream.

PatrickF1 commented 11 months ago

@okobenoko @Drowze did the patch from @rudenkornk fix your problem?

Drowze commented 11 months ago

@PatrickF1 yes! Been using since yesterday and it fixes the problem for me.

My system: Fish: 3.6.1 fzf.fish: I guess v10.0 (updated yesterday via fisher, not sure how to check for specific version) terminal: tmux 3.3a on Alacritty 0.12.2 (9d9982d) OS: Mac OS Ventura 13.2.1 (Macbook Pro 2019)

PatrickF1 commented 11 months ago

I still don't want to make this change but I responded to that issue (link) to make a suggestion for an easy fix in fish. I also socialized it with the maintainers on the Fish chat to see if I can get eyes on it sooner. Fish is also in a sense upstream of fzf.fish, so similar to you, I don't want to be maintaining stuff related to fish's internals.

Drowze commented 11 months ago

I can definitely understand @PatrickF1!

Thank you for the consideration and looking after it though! (and btw, thank you for this amazing project! I migrated from other project to this one well over a year ago, and since then this has been a core piece of my workflow).

Hopefully we'll soon get a supported way to handle this case from fish itself - until then I think this issue has already enough documentation for those who may want to patch their installation.

PatrickF1 commented 5 months ago

Apparently this is fixed in the next fish release!