Skip to content

[BUG REPORT] Keep Option as Alt working with macOS input methods - #18

Merged
Raiden-MeixElysia merged 1 commit into
ELY-Open-Source:mainfrom
totorowldox:feat/option-alt-ime
Oct 24, 2026
Merged

Raiden-MeixElysia merged 1 commit into
ELY-Open-Source:mainfrom
totorowldox:feat/option-alt-ime

Conversation

@totorowldox

Copy link
Copy Markdown
Contributor

Type

  • [FEATURE REQUEST]: a new feature or an improvement
  • [BUG REPORT]: a bug fix
  • [Other]: docs, refactoring, CI, dependencies or chores

What and why

With Option as Alt set to Both, ⌥f typed ƒ while a Chinese input method was active, its built-in English mode included. Selected Option keys now reach the terminal's Alt encoding first.

Bug details

  • Steps to reproduce: on macOS, set Settings › Terminal › Option as Alt to Both, select a Chinese input method (tested: 水杉输入法 Shuangpin), press ⌥f in the terminal.
  • Expected: the program receives ESC f.
  • Actual: the program receives ƒ.
  • Cause and fix: gpui's macOS key path sends printable keys to the input method before key listeners when a non-ASCII input source is active and the view accepts text input. The input method turned Option-f into ƒ, so alt_is_meta never ran. TerminalView now reports accepts_text_input = false on macOS, so key listeners run first; plain text and IME composition/commit still reach the input handler.

How it was tested

  • cargo run --example shot with 水杉输入法 Shuangpin active, reading the bytes a raw-mode program received:
    • before: ⌥f twice → ƒƒ
    • after, Both: ⌥f twice → ESC f ESC f; plain f, Escape and a marked/committed 中文 still arrive
    • after, Left: left ⌥f → ESC f, right ⌥f → ƒ
  • cargo test --locked --lib term::input::tests
  • cargo test --locked --lib term::keys::tests
  • cargo fmt --check

Not run: the full scripts/check.sh; other input methods.

Checklist

  • The title starts with [FEATURE REQUEST], [BUG REPORT] or [Other]
  • Tests and the build pass locally (targeted tests and the shot build passed; full scripts/check.sh not run)
  • Docs are updated if behaviour changed

@totorowldox
totorowldox marked this pull request as ready for review October 22, 2026 12:42
Raiden-MeixElysia added a commit that referenced this pull request Oct 24, 2026
…ds an Option key Option as Alt claims, so that key goes as Alt under an input method and every other key reaches the input method first, as before PR #18, where a plain key under kitty's report-all-keys flag went as CSI u and never reached Pinyin
@Raiden-MeixElysia
Raiden-MeixElysia merged commit b7bfb55 into ELY-Open-Source:main Oct 24, 2026
@Raiden-MeixElysia

Copy link
Copy Markdown
Contributor

@totorowldox Thank you for the fix and the clear report. It is merged in b7bfb55, with one change on top, 831c150.

accepts_text_input = false sent every printable key to the key listener first. That fixed ⌥f, but under kitty's report-all-keys flag (CSI > 8 u) a plain n then went out as CSI 110 u and never reached the input method, so Pinyin could not start a word. Now the terminal declines text only while the key AppKit is handling holds an Option key that Option as Alt claims. Every other key reaches the input method first, as before.

Under WeType Pinyin: Both sends ESC f for either Option; Left and Right send ESC f for their own side and ƒ for the other; Off sends ƒ; a plain n under report-all-keys stays n. It ships in the next release.

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.

2 participants