leo-arch / clifm

The shell-like, command line terminal file manager: simple, fast, extensible, and lightweight as hell.
https://github.com/leo-arch/clifm/wiki
GNU General Public License v2.0
1.35k stars 39 forks source link

Can't autocomplete `j` arguments? #227

Closed tkossak closed 1 year ago

tkossak commented 1 year ago

Describe the bug Is it only me or there's a bug with TAB completion of j arguments? Other commands, like bm autocompletion, work as they should.

To Reproduce Steps to reproduce the behavior:

  1. Run clifm
  2. Write j a and press <TAB> key
  3. The list of possible autocompletions is not displayed, and the cursor goes to the next line. It looks like this:
    <0> $ j a
    <0> $ j a

Expected behavior I expected to see the list of possible autocompletions

Desktop (please complete the following information):

leo-arch commented 1 year ago

Hi @tkossak.

Good news: It's not a general bug, but an environment-specific issue. Bad news: Cannot reproduced it.

A few questions:

Does this happen with any query string? Ex: j QUERY<TAB> Does this happen with no query string at all? Ex: j <TAB> You're using fzf as TAB completer, isn't? In that case, what's your fzf version? Is there some unusual directory name in your jump file (~/.config/clifm/profiles/default/jump.clifm)?

You could try with a fresh jump file. Create a backup copy of the file, remove the original one, and then launch clifm (browse a bit and try to reproduce the issue).

NOTE: Do this from outside clifm. Otherwise, the jump file will be recreated at exit using the internal database loaded at startup.

tkossak commented 1 year ago

I may add that when cursor comes to the next line, I see for fraction of a second part of writing specification: 'dark and it disappears - maybe it will help to pinpoint the issue.

Also tested some more and it happens only inside tmux (v3.3a, my tmux.conf) for both xonsh and bash shells. If I run xonsh/bash outside of tmux, it works perfectly fine.

  1. Happens with any query string eg j QUERY<TAB>, j anything<TAB>, etc
  2. It also happens with no query at all but the result is different: in the new line I see strange writing, and cursor is on letter 'c': image
  3. I didn't set tab completion mode, so clifm uses default fzf. I have fzf 0.39.0 (20230402)
  4. I just deleted my jump.clifm file, clifm recreated it with two lines only:
    2:1685529173:1685529179:/home/kossak/Downloads
    @2400

    but it didn't solve the problem.

Maybe I have something wrong with fzf options set for tmux somewhere...

leo-arch commented 1 year ago

That's good info!

Maybe I have something wrong with fzf options set for tmux somewhere

Quite possible indeed.

For what you've described, maybe this fixes your issue: edit your color scheme file (cs edit) and change FzfTabOptions="--color='dark,...' to FzfTabOptions="--color='16,'. If this doesn't work either, just comment out the whole line. If this fixes the issue, then some setting is just wrong in the FzfTabOptions line. Otherwise, maybe some invalid fzf option is being set from outside clifm.

tkossak commented 1 year ago

changing --color to 16 only changed what I see in next line (word 16 instead of dark): image

And commenting it out completely. image

I'll try to look for fzf options later when I have more time. Thank you for the tips.

leo-arch commented 1 year ago

At least we know the cause: something is wrong with your fzf options. We just need to figure out whether this invalid setting is coming from within or outside clifm (and of course, which it is).

tkossak commented 1 year ago

I cannot find what is causing it, but I found out that:

leo-arch commented 1 year ago

Reproduced! I'll see what I can do.

EDIT: The problem is not fzf-specific: using alternative completers like smenu or fnf/fzy also fails when using xonsh.

tkossak commented 1 year ago

Thank you. For me xonsh + clifm (without tmux) works properly, only when I put them both inside tmux, the problem arises.

leo-arch commented 1 year ago

We have two issues:

  1. xonsh doesn't like single quotes. Remove them from the FfzTabOptions in the color scheme file. This solves the color specification: error.
  2. Unlike other shells, xonsh do not dequote query strings: if we pass --query="my query" to fzf, xonsh passes it verbatim (including the quotes). In this case, there's nothing we can do, because we need to quote the query string to prevent it from being split when it contains spaces (word breakers in general). Otherwise, if we pass --query=my query, the second word will be interpreted by the completer as a new option, which of course is not the case. Maybe there's an option in the xonsh config file forcing it to dequote strings. I'll take a look at it.

EDIT: In case there's no way around this, maybe I could force the use of /bin/sh (instead of whatever shell set by the user) when running the completer (fzf or whatever).

leo-arch commented 1 year ago

Solved. For the time being I took the easier route: force the use of /bin/sh when running the completer (both issues are solved thus in a single stroke).

It should work now on the tmux + xonsh + clifm combo. Please let me know if it works for you too.

tkossak commented 1 year ago

Works, thank you very much!