Replace wezterm.time.call_after with update-right-status-based defer for prompt chaining
Deferring the PromptInputLine open by one tick via wezterm.time.call_after did not fix the InputSelector -> PromptInputLine chaining issue on the user's WezTerm build (the box never appeared at all, straight back to the shell) — consistent with call_after being unavailable/erroring and silently aborting the callback. Replaced it with a pending_action flag drained on the next update-right-status tick, an event hook already confirmed working via the existing status bar, removing the dependency on wezterm.time entirely. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
42
wezterm.lua
42
wezterm.lua
@@ -94,7 +94,23 @@ end)
|
|||||||
-- ------------------------------------------------------------
|
-- ------------------------------------------------------------
|
||||||
local pane_start_times = {}
|
local pane_start_times = {}
|
||||||
|
|
||||||
|
-- InputSelector 선택 콜백 안에서 바로 PromptInputLine을 열면, 선택을 확정한 Enter가
|
||||||
|
-- 새 입력창에도 흘러들어가 즉시 닫혀버린다 (wezterm.time.call_after가 없는 버전에서는
|
||||||
|
-- 그 호출 자체가 에러로 죽어서 아예 아무것도 안 뜨고 밑에 있던 셸이 그대로 보인다).
|
||||||
|
-- 어느 wezterm 버전에서도 이미 동작 중인 update-right-status 틱에 실행을 미뤄서 우회한다.
|
||||||
|
local pending_action = nil
|
||||||
|
|
||||||
|
local function defer(fn)
|
||||||
|
pending_action = fn
|
||||||
|
end
|
||||||
|
|
||||||
wezterm.on("update-right-status", function(window, pane)
|
wezterm.on("update-right-status", function(window, pane)
|
||||||
|
if pending_action then
|
||||||
|
local fn = pending_action
|
||||||
|
pending_action = nil
|
||||||
|
fn(window, pane)
|
||||||
|
end
|
||||||
|
|
||||||
window:set_left_status(wezterm.format({
|
window:set_left_status(wezterm.format({
|
||||||
{ Background = { Color = "#89b4fa" } },
|
{ Background = { Color = "#89b4fa" } },
|
||||||
{ Foreground = { Color = "#1e1e2e" } },
|
{ Foreground = { Color = "#1e1e2e" } },
|
||||||
@@ -206,22 +222,20 @@ local function set_config_value(window, pane, key, value)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function prompt_config_value(window, pane, title, key, initial_value, quote_string)
|
local function prompt_config_value(window, pane, title, key, initial_value, quote_string)
|
||||||
-- InputSelector 선택을 확정하는 Enter가 곧바로 여기서 여는 PromptInputLine에도
|
defer(function(inner_window, inner_pane)
|
||||||
-- 흘러들어가 즉시 닫혀버리는 문제가 있어, 한 틱 뒤로 미뤄서 연다.
|
inner_window:perform_action(
|
||||||
wezterm.time.call_after(0, function()
|
|
||||||
window:perform_action(
|
|
||||||
act.PromptInputLine({
|
act.PromptInputLine({
|
||||||
description = title,
|
description = title,
|
||||||
initial_value = tostring(initial_value),
|
initial_value = tostring(initial_value),
|
||||||
action = wezterm.action_callback(function(inner_window, inner_pane, line)
|
action = wezterm.action_callback(function(cb_window, cb_pane, line)
|
||||||
if not line or line == "" then
|
if not line or line == "" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local value = quote_string and string.format("%q", line) or line
|
local value = quote_string and string.format("%q", line) or line
|
||||||
set_config_value(inner_window, inner_pane, key, value)
|
set_config_value(cb_window, cb_pane, key, value)
|
||||||
end),
|
end),
|
||||||
}),
|
}),
|
||||||
pane
|
inner_pane
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@@ -290,27 +304,27 @@ local ssh_domain_steps = {
|
|||||||
local function prompt_ssh_domain_step(window, pane, step_index, data)
|
local function prompt_ssh_domain_step(window, pane, step_index, data)
|
||||||
local step = ssh_domain_steps[step_index]
|
local step = ssh_domain_steps[step_index]
|
||||||
|
|
||||||
wezterm.time.call_after(0, function()
|
defer(function(inner_window, inner_pane)
|
||||||
window:perform_action(
|
inner_window:perform_action(
|
||||||
act.PromptInputLine({
|
act.PromptInputLine({
|
||||||
description = step.title,
|
description = step.title,
|
||||||
initial_value = step.initial_value,
|
initial_value = step.initial_value,
|
||||||
action = wezterm.action_callback(function(inner_window, inner_pane, line)
|
action = wezterm.action_callback(function(cb_window, cb_pane, line)
|
||||||
if not line or line == "" then
|
if not line or line == "" then
|
||||||
notify(inner_window, "SSH 도메인 추가를 취소했습니다")
|
notify(cb_window, "SSH 도메인 추가를 취소했습니다")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
data[step.field] = line
|
data[step.field] = line
|
||||||
|
|
||||||
if step_index < #ssh_domain_steps then
|
if step_index < #ssh_domain_steps then
|
||||||
prompt_ssh_domain_step(inner_window, inner_pane, step_index + 1, data)
|
prompt_ssh_domain_step(cb_window, cb_pane, step_index + 1, data)
|
||||||
else
|
else
|
||||||
append_ssh_domain(inner_window, inner_pane, data.name, data.remote_address, data.username)
|
append_ssh_domain(cb_window, cb_pane, data.name, data.remote_address, data.username)
|
||||||
end
|
end
|
||||||
end),
|
end),
|
||||||
}),
|
}),
|
||||||
pane
|
inner_pane
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user