fix(tui): accept macOS Option-key chars for file picker toggles#3333
Open
Sayt-0 wants to merge 1 commit into
Open
fix(tui): accept macOS Option-key chars for file picker toggles#3333Sayt-0 wants to merge 1 commit into
Sayt-0 wants to merge 1 commit into
Conversation
On macOS the OS substitutes a Unicode character for Option+key before the terminal receives the event, so the file picker alt+h / alt+i visibility toggles never fire. Accept the characters that the standard US and US-International layouts emit (Option+H -> "˙" U+02D9, Option+I -> "ˆ" U+02C6) as aliases for the existing bindings, keeping alt+h / alt+i as the primary keys. Implements Option B from #2611.
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The changes look correct and well-structured. The filePickerKeyMap struct and defaultFilePickerKeyMap() constructor follow the existing keymap pattern. The Unicode code points U+02D9 (˙) for Option+H and U+02C6 (ˆ) for Option+I are correct for macOS US/US-International layouts, and the switch from direct msg.String() comparisons to key.Matches is the right approach. Both the production code and the tests are sound — no bugs introduced by this PR.
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.
Summary
The file picker
alt+h/alt+ivisibility toggles never fire on macOS. The OS substitutes a Unicode character for Option+key at the input-system level before the terminal receives the event, somsg.String()returns the substituted character instead ofalt+h/alt+i.This implements Option B from #2611: keep
alt+h/alt+ias the primary bindings and accept the macOS-produced characters as aliases. Addresses #2611.Change
msg.String() == "alt+h"checksfilePickerKeyMapstruct (mirrorscostDialogKeyMap)alt+honlyalt+hand˙(U+02D9, macOS Option+H)alt+ionlyalt+iandˆ(U+02C6, macOS Option+I)key.MatchesIssue expectations mapped
alt+h/alt+iworking (Linux, "Option as Meta" enabled)key.NewBinding/ keymap stylefilePickerKeyMap+defaultFilePickerKeyMap()Known limitations (as noted in the issue's Option B section)
ˆ(U+02C6) is a dead key on macOS, so Option+I may compose with the next keystroke rather than arrive as a standalone press in some terminals..and!) remains the cleaner long-term fix and is independent of this change. Option B is the low-risk patch the issue proposed to apply immediately while Option A is discussed.Tests
TestFilePickerToggleHiddenViaMacOSOptionCharandTestFilePickerToggleIgnoredViaMacOSOptionCharsimulate the macOSKeyPressMsgand assert the toggles fire.alt+h/alt+itests continue to pass.KeyPressMsgthe issue documents macOS producing (Textset to U+02D9 / U+02C6); they exercise the binding wiring, not a hardware-captured event. Removing the aliases makes the new tests fail while thealt+h/alt+itests still pass, confirming they are genuine regression guards.Validation
go build ./...,gofmt,go vet,golangci-lint(0 issues), and the fullpkg/tui/dialogtest suite pass.