File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,8 @@ local M = {}
33--- @param pids number[]
44--- @return table<number , number>
55local function get_ports (pids )
6- local pids_to_ports = {}
6+ assert (# pids > 0 , " `get_ports` should only be called with a non-empty list of PIDs to filter by" )
7+
78 local lsof = vim
89 .system ({
910 " lsof" ,
@@ -22,6 +23,7 @@ local function get_ports(pids)
2223 :wait ()
2324 require (" opencode.util" ).check_system_call (lsof , " lsof" )
2425
26+ local pids_to_ports = {}
2527 local pid
2628 for line in lsof .stdout :gmatch (" [^\n ]+" ) do
2729 local prefix = line :sub (1 , 1 )
@@ -55,6 +57,10 @@ function M.get()
5557 return tonumber (line )
5658 end , vim .split (pgrep .stdout , " \n " , { trimempty = true }))
5759
60+ if # pids == 0 then
61+ return {}
62+ end
63+
5864 local pids_to_ports = get_ports (pids )
5965 --- @type opencode.cli.process.Process[]
6066 local processes = {}
You can’t perform that action at this time.
0 commit comments