Skip to content

Commit 3cabaf1

Browse files
author
John Mutuma (from Dev Box)
committed
fix(tmux): forward nav keys directly to mux pane on Windows (psmux)
On Windows with psmux, control keys like C-j passed through Neovim's terminal emulation get mangled (C-j/newline becomes CR/submit). Route nav key passthrough via tmux send-key when a mux parent is available, bypassing the terminal translation layer. Sanitize session names (spaces to hyphens) and sync mux_session so tmux send-keys targets the correct session on psmux.
1 parent 0a5ad1e commit 3cabaf1

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

lua/sidekick/cli/actions.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ local function nav(dir)
4747
return function(terminal)
4848
local at_edge = vim.fn.winnr() == vim.fn.winnr(dir)
4949
if at_edge or terminal:is_float() then
50+
-- When running under a mux backend (e.g., tmux via psmux on Windows),
51+
-- returning the key as an expr string passes through Neovim's terminal
52+
-- emulation, which can mangle control characters (e.g., C-j becomes CR).
53+
-- Send the key directly to the mux pane instead.
54+
if terminal.parent and terminal.parent.send_key then
55+
vim.schedule(function()
56+
terminal.parent:send_key(("C-%s"):format(dir))
57+
end)
58+
return
59+
end
5060
return ("<c-%s>"):format(dir)
5161
end
5262
vim.schedule(function()

lua/sidekick/cli/session/tmux.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,14 @@ function M:submit()
200200
Util.exec({ "tmux", "send-keys", "-t", self.tmux_pane_id, "Enter" })
201201
end
202202

203+
---Send a raw key to a tmux pane
204+
---@param key string tmux key name (e.g., "C-j", "Enter", "Escape")
205+
function M:send_key(key)
206+
if self.mux_session then
207+
Util.exec({ "tmux", "send-keys", "-t", self.mux_session, key })
208+
end
209+
end
210+
203211
function M:dump()
204212
local pane_id = self:pane_id()
205213
if not pane_id then

0 commit comments

Comments
 (0)