ibhagwan / fzf-lua

Improved fzf.vim written in lua
GNU Affero General Public License v3.0
2.15k stars 141 forks source link

Highlights of character matches get reset when matched twice #1012

Closed jbarap closed 7 months ago

jbarap commented 7 months ago

Info

Description

When typing a word twice, the characters matched in the second word will clear the matches from the first one.

To reproduce:

  1. Go to the main neovim repo

  2. Run sh -c "$(curl -s https://raw.githubusercontent.com/ibhagwan/fzf-lua/main/scripts/mini.sh)"

  3. Enter find files with <C-p>

  4. Type "funcs" into the prompt. The first two files will be the correctly matched files funcs.h and funcs.c, with only the "funcs' characters highlighted as matches. image

  5. Type an additional " funcs", such that the full prompt now reads "funcs funcs". The order of the files won't change, but now all the highlights of the matched characters will disappear. image

The behavior doesn't appear to be the same with just the fzf cli: image

Great job with the plugin btw.

ibhagwan commented 7 months ago

This is an upstream bug, apparently when ansi colors are used in the entries it bugs out the second match.

As a workaround you can disable coloring until this gets solved upstream:

:FzfLua files color_icons=false

image

jbarap commented 7 months ago

Huh, interesting. Thank you for the quick response!

ibhagwan commented 7 months ago

Huh, interesting. Thank you for the quick response!

Interesting bug, this only happens to entries that contain an ansi color escape sequence.

Run this in the shell:

echo "\x1b[0;34mblue\x1b[0m\n\x1b[0;34mblue\x1b[0m\n\x1b[0;34mblue\x1b[0m" | fzf --ansi

Now, input bl bl and the match is cleared: image

Now run this (last entry isn't color coded):

echo "\x1b[0;34mblue\x1b[0m\n\x1b[0;34mblue\x1b[0m\n\x1b[0;34mblue\x1b[0m\nblue" | fzf --ansi

If you input bl bl again, the entries that have an ansi escape sequence have the bug, but the clear entry does not: image

ibhagwan commented 7 months ago

Reported upstream: https://github.com/junegunn/fzf/issues/3596

jbarap commented 7 months ago

Thanks! I was just looking for an issue upstream that mentioned something about this.

ibhagwan commented 7 months ago

Thanks! I was just looking for an issue upstream that mentioned something about this.

You're obviously onto some serious edge case here :-)

ibhagwan commented 7 months ago

@jbarap, fixed on upstream master via https://github.com/junegunn/fzf/commit/2a8b65e105ec1a1a9d4cecf947b7267f04453b7c, closing.