Skip to content

--keep-right not keeping right on long lines with search term present #4577

@ulope

Description

@ulope

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.66.1 (brew)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

When long lines are present the --keep-right option seems to lose effect as soon as a search term is entered and results are being highlighted.

Here's an example:

(cat <<EOF
/short/path/file.bla
/A/very/long/path/that/is/shomewhere/deep/on/the/users/hard/disk/and/really/shouldnt/be/this/deeply/nested/somefile.txt
/A/very/long/path/that/is/shomewhere/deep/on/the/users/hard/disk/and/really/shouldnt/be/this/deeply/nested/otherfile.txt
/A/very/long/path/that/is/shomewhere/deep/on/the/users/hard/disk/and/really/shouldnt/be/this/deeply/nested/foobar.txt
EOF
) | fzf --keep-right --preview 'echo "{}"' -q this

Output in an 80x15 terminal:

                                        ╭──────────────────────────────────────╮
                                        │ '/A/very/long/path/that/is/shomewher │
                                        │                                      │
                                        │                                      │
                                        │                                      │
                                        │                                      │
                                        │                                      │
                                        │                                      │
                                        │                                      │
                                        │                                      │
▌ ··really/shouldnt/be/this/deeply/ne·· │                                      │
▌ ··really/shouldnt/be/this/deeply/ne·· │                                      │
▌ ··really/shouldnt/be/this/deeply/ne·· │                                      │
  3/4 ───────────────────────────────── │                                      │
> this                                  ╰──────────────────────────────────────╯

As you can see the search term this has moved to the middle of the line, violating the --keep-right option, even though there would be enough room to show the entire rightmost part of the line while still keeping this in view.

(Of course ignoring keep-right is fine when the search term occurs so far on the left that it's not possible to keep the right edge in view.)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions