Conversation
On macOS, Option+L is @. The terminal forwarded Option as Alt into a non-Darwin libghostty-vt build, so DEC 1036 sent ESC @. Marking Alt consumed still left the raw Alt bit set, and modifyOtherKeys mode 2 encoded that as an Alt sequence. Consume a lone macOS Option that produced a character, and clear those consumed bits from the raw modifier mask before encoding. Ctrl, Meta, Option+arrow, and a lone Shift stay intact. There is no Option-as-Meta setting; this matches Terminal.app with that option off. Tests that stub navigator.platform restore the previous own descriptor, and delete the temporary own property when platform was inherited, including when the stubbed call throws.
Owner
Author
|
Opened upstream. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a German Mac layout,
@is Option+L. The desktop terminal and the web app share this Ghostty surface, and both forwarded Option as Alt into libghostty-vt. That WASM build is not Darwin, so Ghostty'smacos-option-as-alt = falsepath never runs. DEC 1036 turns Option+L intoESC @(readline set-mark), so nothing is typed. The same encoding drops the rest of that Option layer (€,~,[]{}|,\).Electron does not set
AltGraphfor Option, so the existing AltGr bypass does not apply. Option+arrow word motion is a separate path.Fixes pingdotgg#13046
Supersedes pingdotgg#14576
Why
Marking Alt consumed still leaves the raw Alt bit set. modifyOtherKeys mode 2 and Kitty report-all read that bit and emit an Alt sequence even when Alt is also consumed. The raw Alt bit has to be cleared when Option composition is consumed. Shift is cleared only when it participated in that composition. A lone Shift stays in the raw mask.
pingdotgg#14576 left
navigator.platformunrestored whenever it was inherited. Node exposesplatformon the prototype, so saving only an own-property descriptor did nothing and later tests kept the stub. Cleanup now restores a saved own descriptor, and deletes the temporary own property when there was none, insidefinally, including when the stubbed call throws.Change
A lone macOS Option that produces one character is consumed, and those consumed bits are cleared from the raw modifier mask before encoding. Ctrl, Meta, Option+arrow, and a lone Shift stay intact, including Shift+letter under modifyOtherKeys mode 2.
There is no Option-as-Meta setting. This matches Terminal.app with "Use Option as Meta key" off, and Ghostty's default. Option+letter chords that previously became
ESCplus the unshifted letter now type the composed character.Scope and approval
Triaged bug pingdotgg#13046 (
acceptedby juliusmarminge). The change is the terminal key encoder in the web surface the desktop app embeds. Mobile's native terminal is a different path and is unchanged.Verification
From commit
4aeae6d73, Node 24.13.1 (v24.13.1).Formatter, from the repo root:
Result, exit 0:
No further edits.
Lint, from the repo root:
Result, exit 0. The only warning is the existing
no-new-arraynote inghosttyCellText:Unit tests, from
apps/web:Result, exit 0:
Typecheck, from the repo root:
Result, exit 0:
The WASM tests assert the encoded bytes, not only the consumed-mod bitmask:
ESC @/CSI 64;3 u. Consumed Alt without clearing the raw bit is still an Alt sequence under modifyOtherKeys mode 2 (CSI 27;3;64~). The maskencodeKeysends encodes@.\): leaving the composing Shift in the raw mask encodesCSI 27;2;92~. Clearing it encodes\.CSI 27;2;65~.GhosttyTerminalCore.encodeKeyon a MacIntel platform writes@,€,|, and\in the default, modifyOtherKeys, and Kitty disambiguate modes, and the Kitty report-all sequence\x1b[64::108;;64u. Linux and Windows Alt still prefix ESC. Ctrl+C and Option+Left are unchanged.navigator.platformis restored after every encodeKey test. An inherited platform (no own descriptor) is deleted again after a thrown stub, and an own descriptor is put back.Platform checks and Limitations
Checked on Linux x86_64, Node 24.13.1. In this runtime
navigator.platformis the inherited valueLinux x86_64, which is the case that previously leaked an own property.Not checked on a physical German keyboard or Electron on macOS. The assertions pass a platform string into the same encoder the desktop app uses.
Option+letter chords that used to send
ESCplus the unshifted letter now type the composed character. There is no setting to keep Option as Meta.UI Changes
None visual. This changes the bytes the terminal key encoder sends for macOS Option compositions. There is no layout or rendering change to screenshot.
Checklist