Skip to content

action.send_keys() is misleading due to hardcoded Enter #16

@jxyyz

Description

@jxyyz

Problem

action.send_keys() has a hardcoded Enter at the end:

-- lua/wiremux/backend/tmux/action.lua
function M.send_keys(target_id, keys)
    return { "send-keys", "-t", target_id, keys, "Enter" }
end

We can't send arbitrary keystrokes - for example when client running in the target requires sending non-typical key combination (e.g. Ctrl+Enter) for submition or any other purpose.

The function name suggests a general-purpose key sender, but it's actually "type text and press Enter". This is misleading and makes the function unusable for sending arbitrary keystrokes.

Suggestion

Make send_keys a clean low-level primitive — accept string|string[], don't append anything:

function M.send_keys(target_id, keys)
    local cmd = { "send-keys", "-t", target_id }
    if type(keys) == "table" then
        vim.list_extend(cmd, keys)
    else
        table.insert(cmd, keys)
    end
    return cmd
end

Then fix callers to be explicit:

-- submit: explicitly send Enter
action.send_keys(t.id, "Enter")

-- create with shell cmd: explicitly send cmd + Enter
action.send_keys(id, { cmd, "Enter" })

This is a small, non-breaking internal refactor. No public API changes. The behavior stays the same, the code just says what it means.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions