Skip to content

Fix Ctrl+H deleting committed text instead of composing text during IME input - #790

Merged
lawrencecchen merged 1 commit into
manaflow-ai:mainfrom
sminamot:fix/ime-ctrl-backspace
Mar 5, 2026
Merged

lawrencecchen merged 1 commit into
manaflow-ai:mainfrom
sminamot:fix/ime-ctrl-backspace

Conversation

@sminamot

@sminamot sminamot commented Mar 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

During IME composition (e.g. Japanese input), pressing Ctrl+H deletes already-committed text instead of composing (pre-edit) characters. Backspace key works correctly.

Root cause

The Ctrl key fast path in keyDown (GhosttyTerminalView.swift:3009) unconditionally bypasses interpretKeyEvents() and sends key events directly to Ghostty. This skips the IME entirely, so Ctrl+H is treated as a terminal backspace even during composition.

Adding a hasMarkedText() guard to the fast path condition lets Ctrl+key events fall through to interpretKeyEvents() during IME composition, matching Ghostty upstream behavior.

Test plan

  • Launch debug build with ./scripts/reload.sh --tag fix-ime-ctrl-h
  • Open Japanese IME, type hiragana to enter composition state
  • Press Ctrl+H — composing text is deleted (not committed text)
  • Without IME composition, Ctrl+H/C/D etc. work as normal terminal shortcuts

Summary by cubic

Fixes Ctrl+H during IME composition by skipping the Ctrl-key fast path when marked text is present, so composing text is deleted instead of committed text. Ctrl+key events now go through interpretKeyEvents() during composition; normal Ctrl shortcuts remain unchanged outside composition.

Written for commit 132bc6c. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Ctrl key handling to properly respect input method composition, allowing uninterrupted text entry for users utilizing IME.

During IME composition (e.g. Japanese input), Ctrl+H should delete
composing characters via the IME, not bypass it and send a backspace
directly to the terminal. Add a hasMarkedText() check so the fast path
is only taken when no IME composition is active, letting
interpretKeyEvents() handle the key instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel

vercel Bot commented Mar 3, 2026

Copy link
Copy Markdown

@sminamot is attempting to deploy a commit to the Manaflow Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Mar 3, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a086ebc and 132bc6c.

📒 Files selected for processing (1)
  • Sources/GhosttyTerminalView.swift

📝 Walkthrough

Walkthrough

A single-file change to GhosttyTerminalView.swift that adds a guard condition checking hasMarkedText() to both the keyDown and performKeyEquivalent code paths. This prevents Ctrl key input from bypassing IME composition when marked text is present, allowing IME to complete normally.

Changes

Cohort / File(s) Summary
IME Composition Handling
Sources/GhosttyTerminalView.swift
Added hasMarkedText() guard condition to gate immediate Ghostty key processing in Ctrl key paths (keyDown and performKeyEquivalent), preventing Ctrl input from bypassing IME during composition.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 A Ctrl key caught mid-composition's dance,
Now pauses for the IME's rightful chance,
No more the input's hasty, rushing leap—
Let marked text finish ere the codes run deep! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: fixing Ctrl+H behavior during IME input to delete composing text instead of committed text, which directly matches the code change that adds hasMarkedText() guarding.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 1 file

@greptile-apps

greptile-apps Bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes Ctrl+H incorrectly deleting committed text instead of composing text during IME input by adding a hasMarkedText() guard to the Ctrl key fast path. The fix ensures that when IME composition is active (e.g., Japanese hiragana input), Ctrl-modified keys are routed through interpretKeyEvents() instead of bypassing to Ghostty directly.

  • Added && !hasMarkedText() condition to line 3014 in the Ctrl fast path
  • Matches existing IME handling patterns in the codebase (see performKeyEquivalent bypasses)
  • Minimal, surgical fix that only affects the specific fast path during composition
  • Well-supported by existing test infrastructure in CJKIMEInputTests.swift

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • One-line fix that adds a well-tested guard condition to existing fast path logic. The hasMarkedText() method is extensively used throughout the codebase with comprehensive test coverage. The fix is minimal, focused, and follows established patterns for IME handling.
  • No files require special attention

Important Files Changed

Filename Overview
Sources/GhosttyTerminalView.swift Added hasMarkedText() guard to Ctrl key fast path to properly handle IME composition - minimal, focused fix for Ctrl+H during Japanese/CJK input

Last reviewed commit: 132bc6c

@lawrencecchen

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@atani

atani commented Mar 5, 2026

Copy link
Copy Markdown
Contributor

As a Japanese IME user, this is a fix I've been wanting. Ctrl+H deleting committed text during composition has been a real pain point. Looking forward to seeing this merged.

@lawrencecchen
lawrencecchen merged commit bf28f5d into manaflow-ai:main Mar 5, 2026
10 of 11 checks passed
0xble added a commit to 0xble/cmux that referenced this pull request Mar 7, 2026
bn-l pushed a commit to bn-l/cmux that referenced this pull request Apr 3, 2026
During IME composition (e.g. Japanese input), Ctrl+H should delete
composing characters via the IME, not bypass it and send a backspace
directly to the terminal. Add a hasMarkedText() check so the fast path
is only taken when no IME composition is active, letting
interpretKeyEvents() handle the key instead.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai coderabbitai Bot mentioned this pull request Apr 23, 2026
1 of 6 tasks
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.

3 participants