Skip to content

Commit bfa99e9

Browse files
committed
move tunnel port cap check
1 parent 5d5a37b commit bfa99e9

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/lua_files/lua/tunnel_ports.lua

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
---@param port string|integer
22
function _G._nvrh.tunnel_port(port)
33
for _, channel in ipairs(_G._nvrh.get_nvrh_channels()) do
4-
if channel.client.methods['tunnel-port'] then
5-
_G._nvrh._tunnel_port_with_channel(channel_id, port)
6-
end
4+
_G._nvrh._tunnel_port_with_channel(channel.id, port)
75
end
86

97
if not _G._nvrh.mapped_ports[port] then
@@ -14,7 +12,15 @@ end
1412
---@param channel_id integer
1513
---@param port string|integer
1614
function _G._nvrh._tunnel_port_with_channel(channel_id, port)
17-
pcall(vim.rpcnotify, tonumber(channel_id), 'tunnel-port', { tostring(port) })
15+
local channel = vim.api.nvim_get_chan_info(channel_id)
16+
if channel.client ~= nil and channel.client.methods['tunnel-port'] then
17+
pcall(
18+
vim.rpcnotify,
19+
tonumber(channel_id),
20+
'tunnel-port',
21+
{ tostring(port) }
22+
)
23+
end
1824
end
1925

2026
vim.api.nvim_create_user_command('NvrhTunnelPort', function(args)

0 commit comments

Comments
 (0)