Skip to content

Revert "Fix Chinese IME Enter swallowed in terminal (#3762)" - #3846

Merged
austinywang merged 1 commit into
mainfrom
revert-3767-issue-3762-chinese-ime-enter
May 11, 2026
Merged

austinywang merged 1 commit into
mainfrom
revert-3767-issue-3762-chinese-ime-enter

Conversation

@austinywang

@austinywang austinywang commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Reverts #3767


Note

Cursor Bugbot is generating a summary for commit 6871cc5. Configure here.


Summary by cubic

Reverts the Enter-key handling change for Chinese IMEs and restores the previous IME command-key routing in the terminal. Removes the “no-marked-text” IME command path and the Zhuyin Return forwarding test; simplifies modifier checks by inlining the filter in call sites.

Written for commit 6871cc5. Summary will update on new commits.

Summary by CodeRabbit

  • Refactor

    • Updated input method composition handling logic for improved CJK input method support.
    • Streamlined internal modifier-key processing in IME operations.
  • Chores

    • Removed obsolete test case for CJK input method behavior.

Review Change Stack

@vercel

vercel Bot commented May 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cmux Building Building Preview, Comment May 11, 2026 8:04am
cmux-staging Building Building Preview, Comment May 11, 2026 8:04am

@austinywang
austinywang merged commit a183d44 into main May 11, 2026
14 of 20 checks passed
@greptile-apps

greptile-apps Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR reverts #3767, which fixed Chinese IME Enter being swallowed in the terminal. The no-marked-text branch of shouldSuppressGhosttyKeyForwardingAfterIMEHandling loses its shouldKeepNoMarkedIMECommandInsideTextInput guard and now suppresses every text-input-system-handled event (except numpad digits), regardless of key type — including kVK_Return.

  • shouldKeepNoMarkedIMECommandInsideTextInput and hasOnlyTextInputCommandModifiers are removed; the modifier-flag computation is now inlined in two separate functions.
  • The test testZhuyinReturnForwardsToTerminalAfterCompositionIsCleared is removed to match the reverted behavior.
  • No reason for the revert is given in the PR description; the regression it re-introduces (Enter swallowed after Zhuyin composition clears) is covered by the deleted test.

Confidence Score: 4/5

The revert is internally consistent — the logic change, helper removal, and test deletion all align. The re-introduced Enter-swallowing behavior is intentional and documented by the removed test.

The change is a clean, self-consistent revert. The only concern is minor duplication of the modifier-flag strip logic, now repeated verbatim in two functions after the shared helper was removed.

Sources/GhosttyNSView+IMEComposition.swift — contains the duplicated modifier-flag computation worth consolidating.

Important Files Changed

Filename Overview
Sources/GhosttyNSView+IMEComposition.swift Removes shouldKeepNoMarkedIMECommandInsideTextInput and hasOnlyTextInputCommandModifiers; the no-marked-text branch now suppresses all text-input-handled events (except numpad digits) unconditionally, re-introducing the Enter-swallowing regression. Modifier flag logic is now duplicated in two functions.
cmuxTests/CJKIMEMarkedSelectionTests.swift Removes testZhuyinReturnForwardsToTerminalAfterCompositionIsCleared, which is consistent with reverting the production behavior it was verifying.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["shouldSuppressGhosttyKeyForwardingAfterIMEHandling()"] --> B{accumulatedText empty?}
    B -- No --> C[return false]
    B -- Yes --> D{hadMarkedText OR hasMarkedText?}
    D -- Yes --> E{text changed?}
    E -- Yes --> F[return true]
    E -- No --> G{selection changed?}
    G -- Yes --> F
    G -- No --> H{event + isInputMethodSource?}
    H -- No --> C
    H -- Yes --> I["shouldKeepIMECompositionCommandInsideTextInput(event)"]
    D -- No --> J{textInputHandledEvent AND isInputMethodSource?}
    J -- No --> C
    J -- Yes --> K["!shouldAllowDeferredNumpadIMEFallback(event)"]
    subgraph BEFORE ["Before revert (PR #3767)"]
        L["shouldKeepNoMarkedIMECommandInsideTextInput(event) AND !shouldAllowDeferredNumpadIMEFallback(event)"]
        L -- "kVK_Return → false" --> M["return false — Enter reaches terminal"]
        L -- "arrow/space → true" --> N["return true — suppress"]
    end
    subgraph AFTER ["After revert (this PR)"]
        K -- "kVK_Return → true" --> O["return true — Enter SWALLOWED"]
        K -- "numpad digit → false" --> P["return false"]
    end
Loading

Reviews (1): Last reviewed commit: "Revert "Fix Chinese IME Enter swallowed ..." | Re-trigger Greptile

Comment on lines +128 to +131
let flags = event.modifierFlags
.intersection(.deviceIndependentFlagsMask)
.subtracting([.numericPad, .function, .capsLock])
guard flags.isEmpty || flags == [.shift] else { return false }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Duplicated modifier-flag computation

The hasOnlyTextInputCommandModifiers helper that was removed alongside shouldKeepNoMarkedIMECommandInsideTextInput contained the modifier-flag computation now inlined verbatim into both shouldRememberZhuyinCandidateInteraction (line 128–131) and shouldKeepIMECompositionCommandInsideTextInput (line 158–161). If the set of stripped modifiers ever needs to change, two sites must be updated in sync. Extracting this as a private helper would keep the rule in one place.

@coderabbitai

coderabbitai Bot commented May 11, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 16ac1949-8f70-4603-b19e-687d962c3faa

📥 Commits

Reviewing files that changed from the base of the PR and between ae5715e and 6871cc5.

📒 Files selected for processing (2)
  • Sources/GhosttyNSView+IMEComposition.swift
  • cmuxTests/CJKIMEMarkedSelectionTests.swift

📝 Walkthrough

Walkthrough

IME suppression logic refactored: consumed-input no-marked-text suppression now depends solely on deferred numpad fallback eligibility. Shared modifier-check helpers removed and inlined at call sites. Regression test removed.

Changes

IME Suppression Refactoring

Layer / File(s) Summary
Main Suppression Behavioral Change
Sources/GhosttyNSView+IMEComposition.swift
shouldSuppressGhosttyKeyForwardingAfterIMEHandling simplifies the no-marked-text consumed-input branch to depend only on deferred numpad fallback eligibility, removing prior key-code/modifier filtering.
Removed Modifier-Check Helpers
Sources/GhosttyNSView+IMEComposition.swift
Deleted helper functions that encapsulated text-input-specific modifier checks and no-marked-IME-command key filtering.
Inlined Modifier Logic at Call Sites
Sources/GhosttyNSView+IMEComposition.swift
Zhuyin-candidate interaction logic and shouldKeepIMECompositionCommandInsideTextInput now perform modifier filtering inline using device-independent flags with shift/numpad/function/caps-lock exclusions.
Test Removal
cmuxTests/CJKIMEMarkedSelectionTests.swift
Removed testZhuyinReturnForwardsToTerminalAfterCompositionIsCleared test, which is no longer applicable to the simplified suppression logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • manaflow-ai/cmux#3767: Directly related — introduced the modifier-check helper and narrower no-marked-text allowlist that this PR now removes and refactors.
  • manaflow-ai/cmux#3292: Directly related — also modifies the same numpad commit suppression logic, removing modifier-filter helpers and making suppression depend on deferred numpad fallback.
  • manaflow-ai/cmux#3694: Modifies IME key-forwarding/suppression logic in the same file with overlapping refactoring of modifier checks.

Poem

🐰 Helpers once shared now stand alone,

Modifiers inlined, their logic shown,

Numpad fallback guides the way,

Simpler logic saves the day! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revert-3767-issue-3762-chinese-ime-enter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

This branch was successfully deployed

1 active deployment
Preview – cmux — 6871cc55 Deployed May 11, 2026 by vercel[bot]
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.

1 participant