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-tmux with --color=bg: doesn't cover the sides of the border fully #3162

Closed
5 of 10 tasks
ibhagwan opened this issue Feb 11, 2023 · 5 comments
Closed
5 of 10 tasks

Comments

@ibhagwan
Copy link

ibhagwan commented Feb 11, 2023

  • 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
    • bash
    • zsh
    • fish

Problem / Steps to reproduce

Hi again @junegunn and ty for maintaining this amazing project.

When using fzf-tmux in conjunction with the background color option --color=bg:... the right and left sides of the border within the tmux popup have a narrow border colored by the terminal bg color (rather than the one specified by the --color flag).

Example: when calling fzf-tmux without a background color uses the terminal bg color for background:

fzf-tmux -p80%,60%
image
Note that the different background color in my tmux panes comes from having neovim open with a different colorscheme than the terminal one.

But when adding a background color, there are visible narrow columns to the sides of the border with the incorrect color (the terminal bg color):

fzf-tmux -p80%,60% -- --color=bg:red
image

Another example when using fzf-tmux inside neovim where you can clearly see the issue:
image

@junegunn
Copy link
Owner

Can't reproduce the problem.

FZF_DEFAULT_OPTS= fzf-tmux -p80%,60% --color bg:\#663300 --preview 'cat {}'

image

I'm on tmux 3.3a.

Not reproducible on Vim/Neovim either.

colo blue
call fzf#run({'window': {'width': 0.5, 'height': 0.5}, 'options': '--color bg:red'})

image

@ibhagwan
Copy link
Author

Ok, I was able to find the culprit, it seems that fzf-tmux adds --margin at the sides:

fzf/bin/fzf-tmux

Lines 181 to 182 in 96c3de1

if [[ "$opt" =~ "-E" ]]; then
FZF_DEFAULT_OPTS="--margin 0,1 $FZF_DEFAULT_OPTS"

Which I'm then able to override by appending --margin=0,0 at the end of the command so I guess that solves it.

Any particular reason this is hardcoded into fzf-tmux?

@junegunn
Copy link
Owner

I think that's because fzf-tmux used to use the border from tmux, because back then it was not possible to create a popup without borders.

But since tmux 3.3, we're using --border instead, we can get rid of it.

@junegunn
Copy link
Owner

What do you think?

diff --git a/bin/fzf-tmux b/bin/fzf-tmux
index 44c6051..fd3258f 100755
--- a/bin/fzf-tmux
+++ b/bin/fzf-tmux
@@ -179,9 +179,10 @@ trap 'cleanup' EXIT
 
 envs="export TERM=$TERM "
 if [[ "$opt" =~ "-E" ]]; then
-  FZF_DEFAULT_OPTS="--margin 0,1 $FZF_DEFAULT_OPTS"
   tmux_version=$(tmux -V)
-  if [[ ! $tmux_version =~ 3\.2 ]]; then
+  if [[ $tmux_version =~ ^3\.2[a-z]?$ ]]; then
+    FZF_DEFAULT_OPTS="--margin 0,1 $FZF_DEFAULT_OPTS"
+  else
     FZF_DEFAULT_OPTS="--border $FZF_DEFAULT_OPTS"
     opt="-B $opt"
   fi

@ibhagwan
Copy link
Author

ibhagwan commented Feb 13, 2023

What do you think?

Just tested, works great, ty @junegunn!

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

No branches or pull requests

2 participants