Skip to content

Commit 8e322c6

Browse files
committed
fix(provider): add focus back to the neovim pane after a new opencode pane is spawned
1 parent 53a9c69 commit 8e322c6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lua/opencode/provider/wezterm.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ function Wezterm.new(opts)
3030
return self
3131
end
3232

33+
local function focus_pane(pane_id)
34+
vim.fn.system(string.format("wezterm cli activate-pane --pane-id %d", pane_id))
35+
end
36+
3337
---Check if `wezterm` is running in current terminal.
3438
function Wezterm.health()
3539
if vim.fn.executable("wezterm") ~= 1 then
@@ -63,6 +67,8 @@ function Wezterm:get_pane_id()
6367
)
6468
if result and result ~= "" and not result:match("error") then
6569
self.pane_id = result:match("^%d+")
70+
else
71+
self.pane_id = nil
6672
end
6773

6874
return self.pane_id
@@ -104,6 +110,8 @@ function Wezterm:start()
104110

105111
-- Execute and capture the pane ID
106112
local result = vim.fn.system(table.concat(cmd_parts, " "))
113+
focus_pane(vim.env.WEZTERM_PANE)
114+
107115
self.pane_id = result:match("^%d+")
108116
end
109117
end
@@ -125,7 +133,7 @@ function Wezterm:show()
125133
return
126134
end
127135

128-
vim.fn.system(string.format("wezterm cli activate-pane --pane-id %d", pane_id))
136+
focus_pane(pane_id)
129137
end
130138

131139
return Wezterm

0 commit comments

Comments
 (0)