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

Misbehavior if zoxide history length <= 2 #1819

Closed
FreeHarry opened this issue Oct 21, 2024 · 11 comments · Fixed by #1822
Closed

Misbehavior if zoxide history length <= 2 #1819

FreeHarry opened this issue Oct 21, 2024 · 11 comments · Fixed by #1822
Labels
enhancement New feature or request

Comments

@FreeHarry
Copy link

What system are you running Yazi on?

Linux X11

What terminal are you running Yazi in?

kitty

yazi --debug output

Yazi
    Version: 0.3.3 (Arch Linux 2024-09-05)
    Debug  : false
    OS     : linux-x86_64 (unix)

Ya
    Version: 0.3.3 (Arch Linux 2024-09-05)

Emulator
    Emulator.via_env: ("xterm-kitty", "")
    Emulator.via_csi: Ok(Kitty)
    Emulator.detect : Kitty

Adapter
    Adapter.matches: Kitty

Desktop
    XDG_SESSION_TYPE           : Some("x11")
    WAYLAND_DISPLAY            : None
    DISPLAY                    : Some(":0.0")
    SWAYSOCK                   : None
    HYPRLAND_INSTANCE_SIGNATURE: None
    WAYFIRE_SOCKET             : None

SSH
    shared.in_ssh_connection: false

WSL
    WSL: false

Variables
    SHELL              : Some("/usr/bin/zsh")
    EDITOR             : None
    VISUAL             : None
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : None

Text Opener
    default: Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block  : Some(Opener { run: "${EDITOR:-vi} \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

Multiplexers
    TMUX               : false
    tmux version       : tmux 3.5a
    ZELLIJ_SESSION_NAME: None
    Zellij version     : No such file or directory (os error 2)

Dependencies
    file             : 5.45
    ueberzugpp       : No such file or directory (os error 2)
    ffmpegthumbnailer: 2.2.3
    magick           : 7.1.1-39
    fzf              : 0.55.0
    fd               : 10.2.0
    rg               : 14.1.1
    chafa            : 1.14.2
    zoxide           : 0.9.6
    7z               : 17.05
    7zz              : No such file or directory (os error 2)
    jq               : 1.7.1

Did you try the latest nightly build to see if the problem got fixed?

No, and I'll explain why below

Describe the bug

If only one entry is in zoxide history, Yazi shows the message: No directory history in the database, check out the zoxide docs to set it up. Even if are two entries in the history, but one of it is the current working directory, the message appears.

I except that the history is show as soon as there is at least one entry in the history, also if the entry is the current working directory.

Unfortunately I had no possibility to try nightly build.

Minimal reproducer

  • Clear zoxide history
  • Add one new entry to the history
  • Open Yazi and press z

Anything else?

No response

@FreeHarry FreeHarry added the bug Something isn't working label Oct 21, 2024
@sxyazi
Copy link
Owner

sxyazi commented Oct 21, 2024

This is by design - Zoxide cannot trigger the interactive selector when there's only one history entry, which is a limitation of zoxide itself.

Since Yazi passes --exclude when calling the selector, Yazi also has to exclude the cwd from history to avoid the flicker caused by zoxide's execution failure due to only one history found.

:args({ "query", "-i", "--exclude" })

@sxyazi sxyazi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 21, 2024
@sxyazi sxyazi added invalid This doesn't seem right and removed bug Something isn't working labels Oct 21, 2024
@FreeHarry
Copy link
Author

Hmm. On my linux machine zoxide has no problems if only one entry is in the history. It shows it perfectly in interaction with fzf. And if the history contains no entries it outputs just "zoxide: no match found". Is it os-dependent what you mentioned?

@sxyazi
Copy link
Owner

sxyazi commented Oct 21, 2024

Oh, they fixed it in zoxide 0.9.5 (specifically in ajeetdsouza/zoxide@dbe6f18#diff-f1a262a75a15c046693e28608e526e2c3d73fa8266139cf692bd8f7a4aae522fL115, where they removed --select-1 for fzf)

But I can still reproduce it in zoxide 0.9.4:

screenshot-002076

Considering some users might still be using an older version of zoxide, let's keep this behavior for now.

@FreeHarry
Copy link
Author

If you put the --exclude also here...
image

you can reduce the length comparision to 1...
image

Then it only shows the No directory history...-message if HIST_ENTRIES - CWD == 0. And in all other cases the history is shown correctly.

But I couldn't check this to the zoxide-0.9.4 version.

@sxyazi
Copy link
Owner

sxyazi commented Oct 21, 2024

Yes, but that doesn't change the fact that we still need more than 2 (>= 3) history entries, if one of them is cwd itself, to open the interactive selector.

It just shifts the workload Yazi is doing over to zoxide, but it won't help with hacking to fix the interactive behavior of the old zoxide version.

@sxyazi
Copy link
Owner

sxyazi commented Oct 23, 2024

I dug into it and found that zoxide offers a _ZO_FZF_OPTS environment variable, which lets you completely rewrite the fzf parameters to fix the behavior of older zoxide versions, and this env variable has been supported since 0.4.2, will create a PR for it later.

@sxyazi sxyazi reopened this Oct 23, 2024
@sxyazi sxyazi added enhancement New feature or request and removed invalid This doesn't seem right labels Oct 23, 2024
@sxyazi
Copy link
Owner

sxyazi commented Oct 23, 2024

Please try #1822

@FreeHarry
Copy link
Author

I tested it with nightly build on Win11. It works if history length > 0.

But if history length == 0, this message in yazi is shown...
image

and on the command line this message...
image

But I according to lua file, I think this message should be shown in yazi:
No directory history found, check Zoxide's doc to set it up and restart Yazi

Or did I need something to configure before using it?

@sxyazi
Copy link
Owner

sxyazi commented Oct 24, 2024

I can't reproduce it. Are you sure you renamed/deleted the db.zo history database file?

screenshot-002080.mp4

What's your zoxide version? Could you try debugging zoxide.lua a bit as per #1813 (comment) and see if zoxide query returns the expected result on your system?

@FreeHarry
Copy link
Author

I rechecked the new nightly build and it is working now. Maybe I did something wrong before.

Copy link

github-actions bot commented Dec 4, 2024

I'm going to lock this issue because it has been closed for 30 days. ⏳
This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please file a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants