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

NNN does not close Tmux pane on opening a file while preview #1814

Open
8 of 9 tasks
AinTEAsports opened this issue Feb 8, 2024 · 5 comments
Open
8 of 9 tasks

NNN does not close Tmux pane on opening a file while preview #1814

AinTEAsports opened this issue Feb 8, 2024 · 5 comments
Labels

Comments

@AinTEAsports
Copy link

AinTEAsports commented Feb 8, 2024

Environment details (Put x in the checkbox along with the information)

  • Operating System: Linux 6.7.4-arch1-1
  • Desktop Environment: Hyprland
  • Terminal Emulator: Kitty
  • Shell: zsh
  • Custom desktop opener (if applicable):
  • Program options used: -Adeo -Pp
  • Configuration options set: export NNN_PLUG='f:finder;o:fzopen;m:mocq;d:diffs;t:nmount;v:imgview;p:preview-tui;c:fcd'
  • Plugins are installed
  • Issue exists on nnn master

Exact steps to reproduce the issue

  1. Open Kitty
  2. Run tmux
  3. Run nnn -Adeo -Pp (so that it starts with preview files)
  4. Navigate to any file and press enter so that it opens vim to edit the file

The pane showing the preview is not closed on opening of vim (I did not tried to reproduce the bug with any other editor than vim).

@Oxore
Copy link

Oxore commented Feb 10, 2024

You should try patches/restorepreview/mainline.diff. It fixed the issue for me, at least.

@AinTEAsports
Copy link
Author

Looks like it does nothing in my case.

@N-R-K
Copy link
Collaborator

N-R-K commented Feb 13, 2024

Maybe related: #1809

@CityofSirtel
Copy link

I'm pretty sure restorepreview only applies to the internal editor, pressing e, enter handles it with your opener, nuke etc.
# Description: Adds preview pipe to enable closing and re-opening the preview pane when running an undetached editor.
I just copied the toggle_preview from preview_tui in a wrapper that kills the preview and uses tmux to reenable it

#!/usr/bin/env bash

TMPDIR=${TMPDIR:-/tmp}                                     # location of temporary files
PLUG_KEY=$(echo "$NNN_PLUG" | sed 's/.*\(.\):preview-tui.*$/\1/')
NNN_PARENT=${NNN_FIFO#*.}
FIFOPID="$TMPDIR/nnn-preview-tui-fifopid.$NNN_PARENT"
#PREVIEWPID="$TMPDIR/nnn-preview-tui-previewpid.$NNN_PARENT"
#FIFO_UEBERZUG="$TMPDIR/nnn-preview-tui-ueberzug-fifo.$NNN_PARENT"

pkill() { command pkill "$@" >/dev/null 2>&1 ;}
pidkill() {
    if [ -f "$1" ]; then
        PID="$(cat "$1" 2>/dev/null)" || return 1
        kill "$PID" >/dev/null 2>&1
        RET=$?
        wait "$PID" 2>/dev/null
        return $RET
    fi
    return 1
}

run_cmd() {
    if [ -n "$TMUX" ]; then
        if pidkill "$FIFOPID"; then
            "$@"
            tmux send-keys "M-$PLUG_KEY"
        else
            "$@"
        fi
    else
        "$@"
    fi
    return 1
}

then all you have to do to toggle it for any plugin is

source toggle_prev
run_cmd do stuff here

If you wanted it to toggle on file open you'd have to make a custom opener or edit nuke to do something similar, I just open vim in a new tmux window

@luukvbaal
Copy link
Collaborator

luukvbaal commented Feb 24, 2024

Correct, the restorepreview patch hides and restores preview-tui when opening and closing an attached editor. I guess I didn't consider the case for forked programs since we don't know when it closes, or when it makes sense to restore preview-tui.

Despite that, I suppose closing preview-tui unconditionally when a file is opened can make sense as well. Not sure if it makes sense to change the restorepreview patch at this point, although I wouldn't mind it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants