neomacs icon indicating copy to clipboard operation
neomacs copied to clipboard

[Bug]: UI will hang when SPC Tab (doom)

Open definepi opened this issue 1 month ago • 14 comments

Bug summary

我想触发doom的(+workspace/display)功能,快捷键是SPC Tab Tab,但我发现在按SPC Tab时,neomacs就卡住了,按C-g都不能恢复,直到按了右上角的窗口关闭,才可以恢复过来。

我的配置不是原本的doom官方配置,但在原版gnu emacs运行正常的。

Steps to reproduce

加载了doom emacs配置后,随便打开一个文件(我下面的log是打开了private config里的文件),然后按SPC Tab就复现了。 我没用原版doom配置来复现,因为有点难切换。

下面录屏第15秒就开始卡住了(这个对不上下面的log的,视频只是为了演示bug) https://github.com/user-attachments/assets/0a7a027f-4159-4efa-a305-c26075155a1b

Expected behavior

SPC TAB后应该出现这个画面的,再按一次TAB或任何数字应该有对应的行为,但neomacs卡住了。 Image

Neomacs --version output

Neomacs 0.0.20
Git commit: 47fa15cc69ae8f8da1ca3fac25e0beb700e8c118
Source date: 2026-10-24T15:13:18.000000000-04:00
Build: release-pgo for x86_64-unknown-linux-gnu with rustc 1.96.1
Standalone Rust binary for Neomacs (no C dependency)

Platform

Linux (Wayland)

Install source

Prebuilt release asset (downloaded from Releases)

Extra context

neomacs-debug.tar.gz

05:47:19 左右按了SPC Tab 05:47:47 左右按了C-g和一些鼠标点击,没法退出菜单界面 05:48:14 附近按了关闭窗口,输入回答n后,界面可以继续操作了

definepi avatar Oct 31 '26 06:10 definepi

@neomacs-agent we have doom emacs tests, reproduce this issue?

eval-exec avatar Oct 31 '26 06:10 eval-exec

Short answer: not with the current Doom tests — they don't drive interactive keys.

scripts/test-doom-install.sh (the doom install compatibility jobs) only clones Doom and runs doom --force install; it never starts an editor session or sends SPC TAB. The TUI tests that mount the sealed Doom fixture boot Doom for startup/face checks, not for leader-prefix interaction.

I tried extending the install path to an interactive stock-Doom run locally:

  • Running the same steps as the script with a plain cargo build --release binary fails during doom install with Eager macro-expansion failure: excessive-lisp-nesting 1601. Raising max-lisp-eval-depth gets past that, then straight fails because finder-inf is missing — plain cargo build does not generate it; cargo xtask fresh-build --release does. After generating finder-inf, the install proceeded into package builds, but was too slow to finish here because every batch invocation source-bootstraps; I stopped it.
  • That is a local checkout/runtime gap, not evidence about the hang; CI's Doom job uses the fresh-build runtime.

Your debug log does show something useful:

  • At 05:47:19.049, SPC resolves to doom/leader; at .100 TAB resolves SPC TAB to the workspace prefix keymap; the second TAB at .257 does not resolve +workspace/display.
  • Every later key — k, j, 0, 1, f, and C-g — is looked up with the same ["32","9"] sequence and the same keymap binding (+workspace/switch-to-* map); the sequence never grows to three keys.
  • which-key initializes its buffer at 05:47:20.295, and the prefix stays pending until the window is closed.

So this is a prefix key-sequence problem, not +workspace/display itself.

I could not reproduce it with reduced setups on the current build: plain SPC → TAB → TAB in a real TTY, an Evil normal-state leader, an Evil + general.el leader (the mechanism Doom uses), a menu-item/keymap leader, and which-key popups (side-window, custom side-window, custom child frame) all execute SPC TAB TAB and recover from C-g. The remaining difference is your custom config: the log shows +hacks.el switches which-key-popup-type to custom ((after! which-key (when (eq which-key-popup-type 'side-window) (setq which-key-popup-type 'custom which-key-custom-popup-max-dimensions-function …), which none of the stock tests exercise.

Could you share just that (after! which-key …) form from +hacks.el — the three which-key-custom-*-function settings, especially the show/hide functions — or a reduced config that still hangs? With that I can add a Doom TUI test that boots the config and sends SPC TAB, and confirm whether the hang is in the popup or in key-sequence resolution.

neomacs-agent[bot] avatar Oct 31 '26 06:10 neomacs-agent[bot]

@neomacs-agent try to reproduce in neomacs-gui-tests ?

eval-exec avatar Oct 31 '26 06:10 eval-exec

I tried. The neomacs-gui-tests route is blocked in this checkout for three concrete reasons:

  1. The gui target doesn't build on macOS. crates/neomacs-gui-tests/tests/real_gui_smoke/line_navigation.rs:82 references interaction::linux::popup_trace, but interaction::linux is behind #[cfg(target_os = "linux")]. cargo nextest run -p neomacs-gui-tests --test gui … fails with E0433 before running anything. This is pre-existing and unrelated to #647.
  2. The Doom GUI test is Linux-only and needs a materialized fixture. config_env_boot.rs::doom_gui_boot_home_buffer_matches_gnu is #![cfg(target_os = "linux")] and skips unless DoomEnvironment::open() finds the sealed Doom fixture. There is no fixture under target/infra here; materializing it needs the GNU-bootstrapped pinned fixture (cargo run -p xtask -- infra materialize doom).
  3. The harness cannot send Space or Tab. interaction::Key (crates/neomacs-gui-tests/src/interaction/mod.rs) has only Escape, Enter, arrows, Home, End, and X. Both interaction/linux.rs (xdotool) and interaction/macos/Driver.swift (virtual keycodes) would need Space/Tab entries. The macOS real-input driver also needs NeomacsGuiDriver.app and tmp/gui-driver.sock; it isn't running here.

I ran the separate native_display target on macOS; it builds, but its fixture produced no gui_state here (it expects the fresh-built runtime/native session), so it isn't a usable vehicle either.

What I could run was the closest equivalent: the same release binary in a real neo GUI frame with a Doom-shaped leader map (SPC → TAB prefix → command) plus which-key popups (side-window, custom side-window, custom child frame), driven by Lisp-level key events. SPC TAB TAB executed and C-g recovered in every variant; a TUI pty run of the same map behaves the same. So the stock/reduced configuration does not reproduce it.

Your debug log still points at the remaining difference: after SPC TAB, the command loop keeps resolving the same ["32","9"] workspace prefix map for every later key and for C-g, and the sequence never extends to three keys. The log also shows +hacks.el switching which-key-popup-type to custom with a custom dimensions function — the part no stock test covers.

To make this a GUI regression I can add Space/Tab to Key and both drivers, then add a doom-spc-tab scenario that mounts the sealed Doom fixture, sends SPC TAB, and asserts the command runs and the frame stays responsive. I haven't committed that because I can't see it fail locally without the fixture or your custom which-key functions. If the Doom fixture can be materialized on the Linux GUI job, or you can share the (after! which-key …) form from +hacks.el, I can finish it.

neomacs-agent[bot] avatar Oct 31 '26 06:10 neomacs-agent[bot]

@neomacs-agent hold.

eval-exec avatar Oct 31 '26 06:10 eval-exec

The background wait task failed only because its log file was already removed during cleanup; the native-display test result (fixture produced no gui_state) was already captured. No action needed.

neomacs-agent[bot] avatar Oct 31 '26 06:10 neomacs-agent[bot]

Thank you for the report. I need to make gui-tests for doom-emacs work on macos now.

eval-exec avatar Oct 31 '26 06:10 eval-exec

我用原版doom配置(2026-10-29的)测试了,也能复现问题。 尝试用neomacs-0.0.20-x86_64-unknown-linux-gnu.AppImage -nw 2>&1 | tee /home/dark/Downloads/neomacs-debug1.log运行终端版本来复现,也能复现到,但生成的neomacs-debug1.log似乎没有什么有用的信息,我就不传上来了。

definepi avatar Oct 31 '26 07:10 definepi

但生成的neomacs-debug1.log似乎没有什么有用的信息

@definepi , 你这样做只会捕捉 neomacs tui 的 stdout/stderr, 不会捕捉日志。

在终端模式下,要用 RUST_LOG=DEBUG NEOMACS_LOG_FILE=/tmp/debug.log ./neomacs -nw,日志会写到 /tmp/debug.log 里。

DEBUG 级别的日志估计非常大,可以用 split 切割几次,然后逐个压缩,上传过来。

eval-exec avatar Oct 31 '26 07:10 eval-exec

split_log_0.tar.gz

RUST_LOG=debug NEOMACS_LOG=info NEOMACS_LOG_FILE=/home/dark/Downloads/neomacs-debug1.log /home/dark/Downloads/neomacs-0.0.20-x86_64-unknown-linux-gnu.AppImage -nw 这样抓的,分割成1MB一个了。

操作是,进入emacs后,按一下C-g,然后按SPC TAB,等which-key菜单出现,再按TAB,按123456再乱按字母也没反应,按C-g也不行。

definepi avatar Oct 31 '26 08:10 definepi

已复现。谢谢 @definepi 的日志和操作步骤,正是这些信息定位到了问题。

复现条件(使用 issue 里完全相同的构建):

  • Neomacs v0.0.20 发布版,commit 47fa15cc69ae8f8da1ca3fac25e0beb700e8c118(AppImage 解包后运行 neomacs -nw)
  • 全新安装的 stock Doom(doomemacs/doomemacs master,commit 59cdaa32,2026-10-02),无自定义配置
  • TUI 下按 C-g,然后 SPC TAB,等待后按 TAB;此后按 1、2、字母、C-g 均无响应

日志证据:第二次 TAB 之后,read_key_sequence 对按键的查找始终停在 ["32", "9"],从未变成 ["32", "9", "9"];之后每个键(包括 C-g)都用同一个旧序列查找,所以全部被吞掉。

根因:Doom 的 lisp/doom-emacs.el 为了区分 C-i 与 TAB,在 key-translation-map 里给 [?\C-i](TTY 中 TAB 与 C-i 都是事件 9)安装了一个返回 [9] 的翻译函数。旧版 lookup_key_sequence_suffix_translation 扫描后缀翻译时,会接受只匹配到后缀中间、没有覆盖到最后一个事件的翻译;调用方随后把序列截断到匹配起点再拼接替换值,于是 ["32","9","9"] 被截回 ["32","9"],新按键丢失。翻译在每个键上重复应用,所以之后任何键都会被吞掉;C-g 也是作为被截断的后续事件丢弃,根本到不了 quit 处理。

该问题已在 main 修复:commit d2179e90ab fix(keyboard): keep keys after an earlier translation-map match(2026-10-28),只接受结束于后缀最后一个事件的翻译,并新增回归测试 read_key_sequence_keeps_events_after_an_earlier_decode_translation。v0.0.20 发布(10-24)早于这个修复。用当前 main 构建在同样环境下验证:SPC TAB TAB 正常执行 +workspace/display,1/2 与 C-g 也正常。

结论:这是发布版里已经修复的键盘翻译 bug,使用包含 d2179e90ab 的新构建即可解决。

eval-exec avatar Oct 31 '26 08:10 eval-exec

@definepi 我 明天会发布 v0.0.21。

eval-exec avatar Oct 31 '26 08:10 eval-exec

等大佬发新版后我可以再试试,emacs是我主力编辑器,有什么明显bug估计用一下就能发现了。

definepi avatar Oct 31 '26 08:10 definepi

Closing this. The Doom SPC TAB hang came from key translation looping, and d2179e90ab fixes it on main. The fix will ship in v0.0.21.

If you still see this on current main (or v0.0.21 once it is out), please feel free to reopen this issue or open a new one, with the output of M-x emacs-version.

eval-exec avatar Nov 20 '26 16:11 eval-exec