zellij-org / zellij

A terminal workspace with batteries included
https://zellij.dev
MIT License
21.93k stars 666 forks source link

Configuring the default mode to a non-normal mode results in unexpected input behavior #3751

Open WingsZeng opened 1 week ago

WingsZeng commented 1 week ago

Issue description

Configuring the default mode to a non-normal mode, such as 'prompt' in my work environment, leads to unexpected behavior. At startup, I am able to input some letters, which is clearly unexpected. The configured keybinds still work. However, once I switch to normal mode, I am unable to input anything.

I also tried configuring the default mode to 'entersearch' and attempted to input text. The letters appear in the shell instead of the search area.

Minimal reproduction

default_mode "entersearch"

Other Related Information

zellij version 0.41.1

imsnif commented 1 week ago

Hey, what are you trying to achieve?

WingsZeng commented 1 week ago

Hey, what are you trying to achieve?

I previously configured the default mode to "prompt" instead of the usual "normal" mode. Just like in Vim, where you need to press a key to enter "insert" mode, I need to press a key to switch from "prompt" mode to "normal" mode.

It works well in Zellij version 0.40, but after upgrading to version 0.41.1, I'm unable to enter input normally after switching to "normal" mode.

I want to be able to input normally when switching to "normal" mode while the default mode is set to "prompt."

Here is a part of my configuration:

keybinds clear-defaults=true {
    normal {
        bind "Esc" { SwitchToMode "Prompt"; }
    }
    locked {
        bind "Shift Esc" { SwitchToMode "Prompt"; }
    }
    search {
        bind "Esc" { ScrollToBottom; SwitchToMode "Prompt"; }
        bind "j" "Down" { ScrollDown; }
        bind "k" "Up" { ScrollUp; }
        bind "PageDown" { PageScrollDown; }
        bind "PageUp" { PageScrollUp; }
        bind "n" { Search "down"; }
        bind "N" { Search "up"; }
        bind "c" { SearchToggleOption "CaseSensitivity"; }
        bind "w" { SearchToggleOption "Wrap"; }
        bind "o" { SearchToggleOption "WholeWord"; }
    }
    prompt {
        bind "Ctrl d" { CloseFocus; }
        bind "Ctrl v" { SwitchToMode "Locked"; }
        bind "i" { SwitchToMode "Normal"; }
        bind "e" { EditScrollback; SwitchToMode "Locked"; }
        bind "_" { NewPane "Down"; }
        bind "|" { NewPane "Right"; }
        bind "f" { ToggleFocusFullscreen; }
        bind "Space" { TogglePaneEmbedOrFloating; }
        bind "/" { SwitchToMode "EnterSearch"; SearchInput 0; }
        bind "j" "Down" { ScrollDown; }
        bind "k" "Up" { ScrollUp; }
        bind "PageDown" { PageScrollDown; }
        bind "PageUp" { PageScrollUp; }
        bind "Esc" "Enter" "G" { ScrollToBottom; }
        bind "J" { GoToPreviousTab; }
        bind "K" { GoToNextTab; }
        bind "Ctrl h" { MovePane "Left"; }
        bind "Ctrl j" { MovePane "Down"; }
        bind "Ctrl k" { MovePane "Up"; }
        bind "Ctrl l" { MovePane "Right"; }
    }
    entersearch {
        bind "Esc" { SwitchToMode "Prompt"; }
        bind "Enter" { SwitchToMode "Search"; }
    }
    shared {
        bind "Alt =" "Alt +" { Resize "Increase"; }
        bind "Alt -" { Resize "Decrease"; }
        bind "Alt 1" { GoToTab 1; }
        bind "Alt 2" { GoToTab 2; }
        bind "Alt 3" { GoToTab 3; }
        bind "Alt 4" { GoToTab 4; }
        bind "Alt 5" { GoToTab 5; }
        bind "Alt 6" { GoToTab 6; }
        bind "Alt 7" { GoToTab 7; }
        bind "Alt 8" { GoToTab 8; }
        bind "Alt 9" { GoToTab 9; }
        bind "Ctrl t" { NewTab; }
    }
    shared_except "locked" {
        bind "Alt h" { MoveFocus "Left"; }
        bind "Alt l" { MoveFocus "Right"; }
        bind "Alt j" { MoveFocus "Down"; }
        bind "Alt k" { MoveFocus "Up"; }
        bind "Ctrl w" { CloseTab; }
        bind "Alt z" { TogglePaneFrames; }
    }
}

default_mode "prompt"
imsnif commented 1 week ago

I think this was not really supposed to work in the first place... Maybe the new non-colliding keybindings preset will work for you? More info here: https://zellij.dev/tutorials/colliding-keybindings/