zellij-autolock icon indicating copy to clipboard operation
zellij-autolock copied to clipboard

bug: toggle floating does not properly unlock

Open JonnyWhitney opened this issue 1 year ago • 4 comments

zellij --version: zellij 0.41.0

Terminal version: foot version: 1.18.1 +pgo +ime +graphemes -assertions

Operating system: Linux 6.10.10-arch1-1 #1 SMP PREEMPT_DYNAMIC x86_64 GNU/Linux

Issue description

When toggling floating panes in a window that is locked by a program defined in triggers, the ui is not unlocked.

Minimal reproduction

Zellij Config:

plugins {
    autolock location="file:/home/jonny/.config/zellij/zellij-autolock.wasm" {
        triggers "nvim"
    }
}

keybinds {
    normal {
        bind "Enter" {
            WriteChars "\u{000D}";
            MessagePlugin "autolock" {};
        }
    }
    shared_except "normal" "locked" {
        bind "Esc" { SwitchToMode "Normal"; }
    }
    // Standard Mode Bindings
    shared_except "locked" {
        bind "Alt ." { SwitchToMode "Locked"; }
        // Floating Settings
        bind "Alt o" { ToggleFloatingPanes; }
    }
}
  1. Open two panes
  2. Open Neovim in one pane
  • :!zellij action move-focus-or-tab right moves focus and unlocks the ui.
  • :!zellij action toggle-floating-panes opens the floating pane but the ui is still locked.

Other relevant information

Thanks for the work on this! I tried taking a swing at getting this fixed but its been a few years since I've even touched Rust and I've never done much with it. Maybe I am not correctly configuring for this use case so any help would be great!

JonnyWhitney avatar Sep 17 '24 13:09 JonnyWhitney

Can you just do bind "Alt o" { ToggleFloatingPanes; SwitchToMode "Normal"; }.

Or equivalently :!zellij action toggle-floating-panes && zellij action switch-mode normal

theol0403 avatar Sep 26 '24 13:09 theol0403

Can you just do bind "Alt o" { ToggleFloatingPanes; SwitchToMode "Normal"; }.

Or equivalently :!zellij action toggle-floating-panes && zellij action switch-mode normal

That works for swapping into floating panes mode but if I'd swap back to Neovim, Zellij wouldn't autolock again. My workaround for now is just adding the following to my zellij config and manually unlocking if I need to when floating panes are toggled on.

locked {
    bind "Alt o" { ToggleFloatingPanes; }
}

JonnyWhitney avatar Sep 30 '24 18:09 JonnyWhitney

Thanks for the report and the suggested workaround. This seems to be an inherited limitation in the Zellij API. Aram hasn't cut a Zellij release in a while, but has been hard at work on it. I'll revisit this after the next Zellij release.

fresh2dev avatar Oct 08 '24 00:10 fresh2dev

FWIW, when opening a floating pane from within [Neo]vim using the companion plugin, zellij.vim, the floating window is opened in "Normal" mode (unlocked). This also has the helpful effect of opening the floating window in Vim's current working directory.

I have this in my Zellij config.kdl:

    shared_except "locked" {
        /* Put keybindings here if they conflict with Vim or others. */
        ...
        bind "Alt t" { ToggleFloatingPanes; }
        bind "Alt o" { NewPane "Down"; }
        bind "Alt v" { NewPane "Right"; }
        ...
    }

and this in my .vimrc:

" Open floating Zellij pane with `Alt+f`.
execute "set <M-t>=\ef"
noremap <M-t> :ZellijNewPane<CR>

" Open Zellij pane below with `Alt+t`.
execute "set <M-o>=\et"
noremap <M-o> :ZellijNewPaneSplit<CR>

" Open Zellij pane to the right with `Alt+v`.
execute "set <M-v>=\ev"
noremap <M-v> :ZellijNewPaneVSplit<CR>

These configs result in the desired behavior, when using [Neo]vim at least.

fresh2dev avatar Oct 10 '24 01:10 fresh2dev

It seems this is fixed upstream in Zellij v0.41.2 without the need for any workarounds.

Anyone want to confirm this before I close the issue?

fresh2dev avatar Jan 13 '25 23:01 fresh2dev

Just tested and it is now working as expected!

JonnyWhitney avatar Jan 13 '25 23:01 JonnyWhitney