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

Error when using fzopen after changing directory #133

Closed
ram02z opened this issue Oct 23, 2021 · 14 comments · Fixed by jarun/nnn#1215
Closed

Error when using fzopen after changing directory #133

ram02z opened this issue Oct 23, 2021 · 14 comments · Fixed by jarun/nnn#1215
Labels
bug Something isn't working

Comments

@ram02z
Copy link

ram02z commented Oct 23, 2021

To Reproduce

  1. Add fzopen as a plugin
  2. Invoke NNNPicker
  3. Change directory
  4. Invoke fzopen and pick a file
  5. Error shown and the file doesn't get picked

Screenshots

image

Environment:

  • Vim version: NVIM v0.6.0-dev+501-gcb15055c2
  • Plugin manager: packer.nvim
  • Plugin version: 1d5aed3
  • Nnn version: 4.3

Additional context

The error doesn't occur for me if I don't change the directory that nnn.vim was invoked from.

nnn.vim config: https://github.com/ram02z/dotfiles/blob/6ee4aa967a18643a657f7d30cf4435fccb265f05/dot_config/nvim/plugin/50-plugins.lua#L321-L350

@ram02z ram02z added the bug Something isn't working label Oct 23, 2021
@jarun
Copy link
Collaborator

jarun commented Nov 1, 2021

@mcchrish can you please take a look at it? Are you waiting for someone to pitch in?

@mcchrish
Copy link
Owner

mcchrish commented Nov 1, 2021

@jarun I'm waiting for anyone to take a look.
PR is welcome and I can take a review.

@jarun
Copy link
Collaborator

jarun commented Nov 1, 2021

In that case please respond to the defect with a note so someone else bothers to look into it.
What appears to be the problem? Do the error strings help?

@N-R-K
Copy link
Collaborator

N-R-K commented Nov 1, 2021

This is probably a problem with fzopen plugin. I don't use it, so I'm not sure what's going on here. But seems to me that is the offending snippet.

# Check for picker mode
if [ "$3" ]; then
    if [ "$entry" ]; then
        if [ "-" = "$3" ]; then
            printf "%s\n" "$entry"
        else
            printf "%s\n" "$entry" > "$3"
        fi

        # Tell `nnn` to clear its internal selection
        printf "%s" "0p" > "$NNN_PIPE"
    fi

    exit 0
fi

@N-R-K N-R-K added the help wanted Extra attention is needed label Nov 1, 2021
@N-R-K
Copy link
Collaborator

N-R-K commented Nov 1, 2021

Added the "help wanted" label so anyone who's interested can take a look.

@jarun
Copy link
Collaborator

jarun commented Nov 1, 2021

@N-R-K fzopen is working as expected in this block. This is a case of calling a picker plugin while nnn is started in picker mode. See $3 in https://github.com/jarun/nnn/tree/master/plugins#access-level-of-plugins

So, if user is picking files using fzopen(), nnn should not pick files. The picker output file path is passed to the plugin (- if it's stdout) and the plugin will write picked files to it (nnn would skip writing to the output file).

@jarun
Copy link
Collaborator

jarun commented Nov 1, 2021

@mizlan can you please have a look?

@N-R-K
Copy link
Collaborator

N-R-K commented Nov 1, 2021

Can reproduce this with a dummy plugin with that block.

  • Open NnnPicker
  • Hover over a file (in a different directory) and invoke the dummy plugin
#!/bin/sh

# Check for picker mode
entry="$1"
if [ "$3" ]; then
    if [ "$entry" ]; then
        if [ "-" = "$3" ]; then
            printf "%s\n" "$entry"
        else
            printf "%s\n" "$entry" > "$3"
        fi

        # Tell `nnn` to clear its internal selection
        printf "%s" "0p" > "$NNN_PIPE"
    fi

    exit 0
fi

@jarun
Copy link
Collaborator

jarun commented Nov 1, 2021

In explorer mode, it just opens the plugin file.

@jarun
Copy link
Collaborator

jarun commented Nov 1, 2021

That's with pick a plugin method... and expected as per current code.

@N-R-K
Copy link
Collaborator

N-R-K commented Nov 1, 2021

Okay, I know what's going on. The plugin is printing only filename, not full path. So if you change directory it becomes a problem.

@jarun
Copy link
Collaborator

jarun commented Nov 1, 2021

OK. I fixed the other issue with opening the plugin (instead of run) at jarun/nnn@bdbd182.

@jarun
Copy link
Collaborator

jarun commented Nov 1, 2021

@ram02z the fzopen plugin is fixed. Please confirm if the patch works for you.

@ram02z
Copy link
Author

ram02z commented Nov 6, 2021

@ram02z the fzopen plugin is fixed. Please confirm if the patch works for you.

The patch works great, thanks for the fix @N-R-K !

KenJean pushed a commit to KenJean/nnn that referenced this issue Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants