From 8afe869b02c1d8e173c67c992b951721219d60c4 Mon Sep 17 00:00:00 2001 From: gm Date: Sat, 18 Jul 2026 01:38:36 +0900 Subject: [PATCH] Cache system font list to stop the font-picker flash wezterm ls-fonts --list-system runs synchronously and blocks the UI thread while it walks every installed font, which happens right after the previous menu overlay closes -- during that gap the underlying shell was briefly visible before the font picker rendered. Caching the parsed result means the blocking call only happens once; gui-startup also warms the cache immediately so even the first font settings visit in a session is instant. Co-Authored-By: Claude Sonnet 5 --- wezterm.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wezterm.lua b/wezterm.lua index b90b17b..83d3238 100644 --- a/wezterm.lua +++ b/wezterm.lua @@ -293,8 +293,15 @@ local function prompt_font(window, pane, which) ) end --- `wezterm ls-fonts --list-system` 결과를 파싱해 설치된 폰트 이름 목록을 만든다 +-- `wezterm ls-fonts --list-system`는 동기(블로킹) 호출이라 매번 실행하면 메뉴 전환 사이에 +-- 밑에 있던 셸이 잠깐 보이는 깜빡임이 생긴다. 한 번 조회한 결과를 캐싱해 재사용한다 +local system_fonts_cache = nil + local function list_system_fonts() + if system_fonts_cache then + return system_fonts_cache + end + local exe = is_windows and (wezterm.executable_dir .. "\\wezterm.exe") or (wezterm.executable_dir .. "/wezterm") local ok, stdout = wezterm.run_child_process({ exe, "ls-fonts", "--list-system" }) if not ok or not stdout then @@ -311,6 +318,7 @@ local function list_system_fonts() end end table.sort(fonts) + system_fonts_cache = fonts return fonts end @@ -749,6 +757,7 @@ end) -- 시작 시 첫 화면으로 메인 메뉴를 띄워 설정과 연결 메뉴에 바로 접근합니다. wezterm.on("gui-startup", function(cmd) local tab, pane, window = wezterm.mux.spawn_window(cmd or {}) + list_system_fonts() -- 폰트 목록을 미리 캐싱해서, 나중에 폰트 설정 메뉴에서 조회 지연으로 화면이 깜빡이지 않게 함 show_main_menu(window:gui_window(), pane) end)