Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc7bb7dd

Browse files
authored
fix(wezterm): track pane_id as opposed to tracking title, and remove dependency on jq (#93)
Fixes#92
1 parent9dad7da commitc7bb7dd

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

‎lua/opencode/provider/wezterm.lua‎

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,44 @@ function Wezterm.health()
5252
returntrue
5353
end
5454

55-
---Get the `wezterm` pane ID where `opencode` is running.
55+
---Retrieve the `wezterm` pane ID associated with the running `opencode` instance.
56+
---This establishes a direct link between the spawned `opencode` pane and its ID.
57+
---If the `opencode` pane is closed and a new one is created manually, it cannot
58+
---still be tracked by this ID.
5659
---@returnstring|nil pane_id
5760
functionWezterm:get_pane_id()
5861
localok=self.health()
5962
ifok~=truethen
6063
error(ok)
6164
end
6265

63-
localbase_cmd=self.cmd:match("^%S+")orself.cmd
64-
localresult=vim.fn.system(
65-
string.format("wezterm cli list --format json 2>&1 | jq -r '.[] | select(.title ==\"%s\") | .pane_id'",base_cmd)
66-
)
67-
ifresultandresult~=""andnotresult:match("error")then
68-
self.pane_id=result:match("^%d+")
69-
else
66+
ifself.pane_id==nilthen
67+
returnnil
68+
end
69+
70+
localresult=vim.fn.system("wezterm cli list --format json 2>&1")
71+
72+
ifresult==nilorresult==""orresult:match("error")then
73+
self.pane_id=nil
74+
returnnil
75+
end
76+
77+
localsuccess,panes=pcall(vim.json.decode,result)
78+
ifnotsuccessortype(panes)~="table"then
7079
self.pane_id=nil
80+
returnnil
81+
end
82+
83+
-- Search for the pane in the list
84+
for_,paneinipairs(panes)do
85+
iftostring(pane.pane_id)==tostring(self.pane_id)then
86+
returnself.pane_id
87+
end
7188
end
7289

73-
returnself.pane_id
90+
-- Pane was not found in the list
91+
self.pane_id=nil
92+
returnnil
7493
end
7594

7695
---Create or kill the `opencode` pane.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp