Skip to content

fix(tui): let AltGr-typed "/" reach the composer instead of opening help (#4723) - #4977

Open
yyyCode wants to merge 1 commit into
Hmbown:mainfrom
yyyCode:fix/altgr-slash-help-overlay
Open

fix(tui): let AltGr-typed "/" reach the composer instead of opening help (#4723)#4977
yyyCode wants to merge 1 commit into
Hmbown:mainfrom
yyyCode:fix/altgr-slash-help-overlay

Conversation

@yyyCode

@yyyCode yyyCode commented Jul 29, 2026

Copy link
Copy Markdown

Summary

Fixes #4723.

On Windows, AltGr is reported to applications as Ctrl+Alt. On the Brazilian ABNT2 layout / is AltGr+Q, which arrives as Ctrl+Alt+Q and was matched against the global Ctrl-/ help chord — so the help overlay opened every time the reporter tried to type a slash. AZERTY and other Latin layouts hit the same class of bug for characters behind AltGr. The reporter isolated it cleanly: AltGr+W (?) works because there's no Ctrl-? binding, so only the Ctrl-/ chord is affected.

This is the same bug class as the sidebar-focus AltGr fix in #2863/#2867, which scoped its fix to Alt-!/Alt-@/etc. but not the one global chord (Ctrl-/) that this issue hits.

Fix

is_help_shortcut (crates/tui/src/tui/shell_key_routing.rs) now treats any AltGr chord as text and falls through to the composer, instead of matching it as help. It reuses the existing platform-gated key_hint::is_altgr primitive that the composer's own is_plain_char guard already uses, so the help matcher and the composer agree exactly on what counts as layout text. Once the overlay stops stealing the key, the composer inserts the literal / (AltGr chords already qualify as plain text on Windows via key_hint::has_ctrl_or_alt).

Behavior preserved:

  • Plain Ctrl-/ still opens help.
  • Legacy Ctrl-7 / Ctrl-_ unit-separator fallbacks still open help.
  • Alt+? stays live (Alt-only, not AltGr).
  • Off Windows, is_altgr is always false, so a genuine Ctrl+Alt+/ chord is unaffected.

Also adds a KEYBINDINGS.md note documenting the AltGr behavior (issue was tagged documentation).

Testing

Full disclosure: this machine has no MSVC toolchain installed (mimalloc-sys can't build under the gnu toolchain either), so I could not run the workspace cargo gates locally. What I did verify:

  • rustfmt --edition 2024 --check clean on the changed Rust file
  • Logic verified by extracting is_help_shortcut into a standalone harness (replicating crossterm KeyModifiers semantics) and asserting all chords for both Windows and non-Windows is_altgr behavior — all pass
  • scripts/check-coauthor-trailers.py passes
  • cargo fmt --all -- --check — not run locally (no MSVC)
  • cargo clippy --workspace ... — not run locally (no MSVC)
  • cargo test --workspace ... — not run locally (no MSVC); please rely on CI for the added regression tests

Added regression tests are platform-split:

  • altgr_typed_slash_is_text_not_the_help_chord (#[cfg(windows)]) — AltGr /, 7, _ fall through; plain Ctrl-/ still opens help.
  • ctrl_alt_slash_still_opens_help_off_windows (#[cfg(not(windows))]) — genuine Ctrl+Alt+/ still opens help.

Checklist

  • Updated docs or comments as needed (KEYBINDINGS.md + inline rationale)
  • Added or updated tests where relevant
  • Verified TUI behavior manually — could not launch a build locally (no MSVC linker); reasoned through the composer key path instead
  • No Co-authored-by trailers added (agent-assisted; issue reporter credited via Reported-by)

On Windows, AltGr is reported to applications as Ctrl+Alt. On the
Brazilian ABNT2 layout `/` is AltGr+Q, which arrives as Ctrl+Alt+Q and
was matched against the global `Ctrl-/` help chord, so the help overlay
opened every time the user tried to type a slash. AZERTY and other
Latin layouts hit the same class of bug for characters behind AltGr.

`is_help_shortcut` now treats any AltGr chord as text and falls through
to the composer, reusing the platform-gated `key_hint::is_altgr`
primitive the composer's own `is_plain_char` guard already uses so the
two agree exactly on what counts as text. Plain `Ctrl-/` still opens
help, `Alt+?` stays live, and off Windows a genuine `Ctrl+Alt+/` chord
is unaffected. Same philosophy as the sidebar-focus AltGr fix in
Hmbown#2863/Hmbown#2867, extended to the one global chord it missed.

Adds platform-split regression tests and a KEYBINDINGS.md note on the
AltGr behavior.

Fixes Hmbown#4723.

Reported-by: @nicolassmotta
@yyyCode
yyyCode requested a review from Hmbown as a code owner July 29, 2026 18:09
@github-actions

Copy link
Copy Markdown
Contributor

Thanks @yyyCode for taking the time to contribute.

This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered.

Please read CONTRIBUTING.md for the expected contribution shape. A maintainer can grant recurring PR access by commenting /lgtm on a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: AltGr+Q on Brazilian ABNT2 layout opens help overlay instead of typing "/"

2 participants