Skip to content

Failure to execute commands with send() on Windows #31

@Arax20

Description

@Arax20

I just installed betterTerm to use with code_runner on Windows 11.

Commands sent via \betterTerm.send() types the command to terminal but requires manual Enter to execute.
This appears to be due to \n being sent without \r so the appended CR isn't being recognised on Windows.
Adding \r to turn it into \r\n resolves the issue locally (here's my quick fix):

if vim.loop.os_uname().sysname == "Windows_NT" then
  local ok, bt = pcall(require, "betterTerm")
  if ok and bt and not bt.__patched_for_cr then
    bt.__patched_for_cr = true
    local orig = bt.send
    bt.send = function(command, index, press)
      -- force a CR so shells that ignore LF still execute
      return orig((command or "") .. "\r", index, press)
    end
  end
end

I’m happy to open a PR if this approach is acceptable.

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