ITADN

GUI and TUI menus not working: click/F10 produce no action

#117Openeval-exec 创建于 2026-05-21
bug
E
eval-execcommented
## Bug Report Both the GUI menu bar and TUI menu are non-functional. Clicking on GUI menu bar items produces no response, and the TUI menu bar items are not rendered/dispatched correctly. ### Reproduction **GUI:** 1. Start neomacs in GUI mode 2. Observe the menu bar with items (File, Edit, Options, Buffers, Tools, Help) 3. Click on any menu bar item 4. **Expected:** A dropdown/popup menu appears 5. **Actual:** Nothing happens **TUI:** 1. Start neomacs in TUI mode (`neomacs -nw`) 2. Row 0 should show menu bar items like "File Edit Options ..." 3. Press F10 to trigger `tmm-menubar` 4. **Expected:** `tmm-menubar` menu appears 5. **Actual:** Menu items may not render correctly on row 0, or F10 does not trigger tmm-menubar ### Root Cause Analysis #### Bug 1: `resolve_menu_bar_submenu` only checks global-map, not local-map In `neovm-core/src/keyboard.rs`, the `resolve_menu_bar_submenu` function only looks up the submenu keymap in `global-map`'s `[menu-bar]` sub-keymap. It does not check the current buffer's local map (major-mode map). This means: - `collect_menu_bar_entries()` collects key names from BOTH global and local maps (e.g., `Lisp-Interaction` from `lisp-interaction-mode-map`) - `resolve_menu_bar_submenu()` only looks in the global-map, so local-map entries fail to resolve → returns NIL → popup is never shown Even for global items like File/Edit, this creates an inconsistency with how GNU Emacs resolves menu-bar entries. #### Bug 2: TTY menu bar rendering may not work in all configurations The TUI comparison tests (`neomacs-tui-tests/tests/menus.rs`) show that neomacs row 0 is empty while GNU Emacs shows "File Edit Options Buffers Tools Lisp-Interaction Help". This may be due to the neomacs binary failing to load its runtime image in the test environment. ### Fix The fix updates `resolve_menu_bar_submenu` to walk the active keymaps in the same order as `collect_menu_bar_entries` — global-map first, then the current buffer's local map. This mirrors GNU Emacs's `x_activate_menubar` / `lw_popup_menu` behavior where major-mode menu entries are resolved correctly. ### GNU Emacs Semantics GNU Emacs `keyboard.c:menu_bar_items` walks both the global map and the local map to collect menu items. The corresponding submenu resolution in `x_activate_menubar` also checks both maps. Neomacs must have 100% same semantics. ### Test Evidence The TUI test `menu_bar_displays_top_level_items` shows: ``` GNU row 0: |File Edit Options Buffers Tools Lisp-Interaction Help| NEO row 0: || (empty) ``` The fix adds two new unit tests: - `resolve_menu_bar_submenu_finds_local_map_entry` - verifies local-map entries resolve - `resolve_menu_bar_submenu_global_map_takes_precedence_over_local` - verifies global-map wins on conflict
1 条评论