Skip to content

zoxide-menu outputs path prefixed with cwd #1126

Open

Description

@jabdinghoff

In my config I have

source vendor/nu_scripts/custom-menus/zoxide-menu.nu

and when I now press ctrl o and select a directory I end up with

$ C:\Users\jabdinghoff\IdeaProjects\C:\Users\jabdinghoff\AppData\Roaming\nushell

where the first part is my current working directory and the second part is what I selected

Activity

  1. fdncred commented on Jun 2, 2025

    @fdncred
    Contributor

    Sounds like a bug in the script. The nushell maintainers don't really support the scripts here but just the repo. Feel free to submit a fix for it and we could land it.

  2. jabdinghoff commented on Jun 2, 2025

    @jabdinghoff
    Author

    Maybe this is actually a nushell bug?

    The script def has a faulty regex

    It should be

    zoxide query -ls $buffer
    | parse -r '(?P<description>\d+(?:\.\d+)?)\s+(?P<value>.+)'

    instead of

    zoxide query -ls $buffer
    | parse -r '(?P<description>[0-9]+) (?P<value>.+)'

    which only gets the last digit from the decimal scores

    But what looks like a bug to me:

    def __test_menu [] {
      {
        name: test_menu
        only_buffer_difference: true
        marker: "| "
        type: { 
          layout: columnar
          page_size: 3
        }
        style: {
          text: blue
          selected_text: blue_reverse
          description_text: yellow
        }
        source: { |buffer, position|
          [{description: 0, value: "AAAA"}, {description: 1, value: "AAAB"}, {description: 3, value:"AAAC"}]
        }
      }
    }

    this here similarly selects AAAAAAC, so some kind of common prefix + selected

    but the exact same setup with layout: list works as expected. Same with the zoxide menu, using list works flawlessly.

    I will report this at the nushell repo and depending on that make a pr to fix the regex, i guess?

  3. fdncred commented on Jun 2, 2025

    @fdncred
    Contributor

    @ysthakur any ideas about this?

  4. ysthakur commented on Jun 3, 2025

    @ysthakur
    Member

    I think jabdinghoff is right, this is probably a Reedline bug with partial completions. The list menu's unaffected because it doesn't do partial completions, whereas the columnar and IDE menus do. I suspect the problem is in menu_functions::can_partially_complete (also, turns out find_common_string doesn't handle suggestions that are substrings of the first suggestion, not sure if that bug is related though).

    I will report this at the nushell repo and depending on that make a pr to fix the regex, i guess?

    Both of those would be helpful, but could you report this in the Reedline repo rather than the Nushell one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions