Fix PromptInputLine closing immediately after InputSelector, split SSH domain entry into steps

Selecting a settings item from an InputSelector menu (font size, line height,
color scheme, opacity, scrollback lines, max FPS, SSH domain add) would open
a PromptInputLine that closed instantly, dumping back to the shell — the
Enter that confirmed the InputSelector choice was bleeding into the newly
opened PromptInputLine. Deferring the PromptInputLine open by one tick via
wezterm.time.call_after fixes it. SSH domain registration now asks for name,
address, and username one at a time instead of a single comma-separated line.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 19:01:02 +09:00
parent 0876d2656c
commit 672cc22b0b

View File

@@ -206,20 +206,24 @@ local function set_config_value(window, pane, key, value)
end
local function prompt_config_value(window, pane, title, key, initial_value, quote_string)
window:perform_action(
act.PromptInputLine({
description = title,
initial_value = tostring(initial_value),
action = wezterm.action_callback(function(inner_window, inner_pane, line)
if not line or line == "" then
return
end
local value = quote_string and string.format("%q", line) or line
set_config_value(inner_window, inner_pane, key, value)
end),
}),
pane
)
-- InputSelector 선택을 확정하는 Enter가 곧바로 여기서 여는 PromptInputLine에도
-- 흘러들어가 즉시 닫혀버리는 문제가 있어, 한 틱 뒤로 미뤄서 연다.
wezterm.time.call_after(0, function()
window:perform_action(
act.PromptInputLine({
description = title,
initial_value = tostring(initial_value),
action = wezterm.action_callback(function(inner_window, inner_pane, line)
if not line or line == "" then
return
end
local value = quote_string and string.format("%q", line) or line
set_config_value(inner_window, inner_pane, key, value)
end),
}),
pane
)
end)
end
local function show_font_settings(window, pane)
@@ -274,27 +278,45 @@ local function append_ssh_domain(window, pane, name, remote_address, username)
window:perform_action(act.ReloadConfiguration, pane)
end
-- SSH 도메인 등록을 이름 -> 주소 -> 사용자명 순서로 한 칸씩 물어봄
-- (WezTerm에는 입력칸을 여러 개 한 화면에 배치하는 폼 위젯이 없어, 한 줄짜리
-- PromptInputLine을 단계별로 이어서 띄우는 방식으로 흉내낸다)
local ssh_domain_steps = {
{ field = "name", title = "SSH 이름 (1/3, 예: prod)", initial_value = "" },
{ field = "remote_address", title = "SSH 주소 (2/3, 예: myserver.example.com)", initial_value = "" },
{ field = "username", title = "SSH 사용자명 (3/3, 예: ubuntu)", initial_value = "" },
}
local function prompt_ssh_domain_step(window, pane, step_index, data)
local step = ssh_domain_steps[step_index]
wezterm.time.call_after(0, function()
window:perform_action(
act.PromptInputLine({
description = step.title,
initial_value = step.initial_value,
action = wezterm.action_callback(function(inner_window, inner_pane, line)
if not line or line == "" then
notify(inner_window, "SSH 도메인 추가를 취소했습니다")
return
end
data[step.field] = line
if step_index < #ssh_domain_steps then
prompt_ssh_domain_step(inner_window, inner_pane, step_index + 1, data)
else
append_ssh_domain(inner_window, inner_pane, data.name, data.remote_address, data.username)
end
end),
}),
pane
)
end)
end
local function prompt_ssh_domain(window, pane)
window:perform_action(
act.PromptInputLine({
description = "SSH 도메인 추가: 이름,주소,사용자명",
initial_value = "myserver,myserver.example.com,youruser",
action = wezterm.action_callback(function(inner_window, inner_pane, line)
if not line or line == "" then
return
end
local name, remote_address, username = line:match("^%s*([^,]+)%s*,%s*([^,]+)%s*,%s*([^,]+)%s*$")
if not name or not remote_address or not username then
notify(inner_window, "형식: 이름,주소,사용자명 예: prod,10.0.0.10,ubuntu")
return
end
append_ssh_domain(inner_window, inner_pane, name, remote_address, username)
end),
}),
pane
)
prompt_ssh_domain_step(window, pane, 1, {})
end
local function show_connection_settings(window, pane)