From 9a03af7cb752f46b9efa85fc132d9281f5672f23 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Wed, 11 Jan 2023 23:23:28 -0800 Subject: [PATCH] fix: url formatting errors when ssh connection specifies port --- lua/oil/adapters/ssh.lua | 4 ++-- lua/oil/adapters/ssh/connection.lua | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/oil/adapters/ssh.lua b/lua/oil/adapters/ssh.lua index c36630d..b71c503 100644 --- a/lua/oil/adapters/ssh.lua +++ b/lua/oil/adapters/ssh.lua @@ -62,16 +62,16 @@ end ---@param url oil.sshUrl ---@return string local function url_to_scp(url) - local pieces = {} + local pieces = { "scp://" } if url.user then table.insert(pieces, url.user) table.insert(pieces, "@") end table.insert(pieces, url.host) - table.insert(pieces, ":") if url.port then table.insert(pieces, string.format(":%d", url.port)) end + table.insert(pieces, "/") table.insert(pieces, url.path) return table.concat(pieces, "") end diff --git a/lua/oil/adapters/ssh/connection.lua b/lua/oil/adapters/ssh/connection.lua index 22633e0..8c612cd 100644 --- a/lua/oil/adapters/ssh/connection.lua +++ b/lua/oil/adapters/ssh/connection.lua @@ -48,9 +48,6 @@ function SSHConnection.new(url) if url.user then host = url.user .. "@" .. host end - if url.port then - host = string.format("%s:%d", host, url.port) - end local command = { "ssh", host, @@ -61,6 +58,10 @@ function SSHConnection.new(url) -- anything prior to that, it *will* appear. The first line gets swallowed. "echo '_make_newline_'; echo '===READY==='; exec /bin/bash --norc", } + if url.port then + table.insert(command, 2, "-p") + table.insert(command, 3, url.port) + end local self = setmetatable({ host = host, meta = {},