zellij-org / zellij

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

Process escape character sequences properly in config KDL #3396

Open samholmes opened 1 month ago

samholmes commented 1 month ago

I have this in my config:

    normal clear-defaults=true {
        bind "\u0000" { SwitchToMode "tab"; }
    }

I'm trying to bind the "\x00" character to switch to "tab" mode. But when running Zellij I get:

  × Failed to parse Zellij configuration
   ╭─[/Users/samholmes/.config/zellij/config.kdl:2:1]
 2 │     normal clear-defaults=true {
 3 │         bind "\u0000" { SwitchToMode "tab"; }
   ·                ▲
   ·                ╰── Kdl Deserialization Error
 4 │     }
   ╰────
  help: For more information, please see our configuration guide: https://zellij.dev/documentation/
        configuration.html

I'm running Zellij 0.40.1.

My old YAML file contained:

keybinds:
  normal:
    - unbind: true
    # Switch Modes (only one switch)
    - action: [SwitchToMode: Tab]
      key: [Char: "\x00"]
    # - action: [SwitchToMode: Locked]
    #   key: [Esc]

Which can compile to KDL, but it causes my KDL file to contain the character "" in my file (which is the escaped character), which causes my KDL file to be mis-interpretted as a binary file instead of a text file.

The fix for this would mean that whatever KDL parser that Zellij is using must respect escape sequences like "\x00" or "\u0000".