junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
61.81k stars 2.35k forks source link

Add --wrap option and 'toggle-wrap' action #3887

Closed junegunn closed 1 week ago

junegunn commented 1 week ago

With the multi-line support, it wasn't too hard to implement line wrap of long items. Should we apply this by default to CTRL-R bindings?

Needs more testing.

Close #3619 Close #2236 Close #577 Close #461

LangLangBart commented 1 week ago

Needs more testing.

I noticed some gaps in the border when interacting with the listed values. See the GIF below for more clarity.

Terminal: iTerm2 Font: Monaco (tested other fonts, but issue remained)

fc -rl 1 | FZF_DEFAULT_OPTS="" fzf \
  --tac \
  --wrap \
  --preview 'bat -pl zsh --color=always {f2..}'

Should we apply this by default to CTRL-R bindings?

Some might prefer it, but on my small terminal, I would probably disable it again. I find the left image below more appealing.

junegunn commented 1 week ago

Thanks for the input, really appreciated.

Some might prefer it, but on my small terminal, I would probably disable it again. I find the left image below more appealing.

Agreed. It doesn't look quite right. Maybe some extra indentation would help, but I'm not sure.

junegunn commented 1 week ago

I noticed some gaps in the border when interacting with the listed values.

This should be fixed now.

Maybe some extra indentation would help, but I'm not sure.

Now we can add a tab indentation using --wrap-sign.

export FZF_CTRL_R_OPTS=$'--wrap --wrap-sign "\t↳ "'

This does help a little, but I can't really say I prefer it over --no-wrap. Enabling wrapping via toggle-wrap only when necessary seems like the best option.

export FZF_CTRL_R_OPTS=$'--bind ctrl-/:toggle-wrap --wrap-sign "\t↳ "'
LangLangBart commented 1 week ago

Everything works smoothly. Did you consider adding a new label when --wrap is enabled, similar to --track ?

It's just something I noticed when testing the command below:

fzf --wrap --track --multi --bind 'ctrl-s:toggle-sort'

Might actually not be needed; users can see it in the list when the lines are long enough.

junegunn commented 1 week ago

Thanks for testing it!

Did you consider adding a new label when --wrap is enabled

No, I hadn't thought about it. As you mentioned, --wrap is clearly visible, unlike "track" or "sort", so I don't think it's necessary.