Type forced English directly, without an underlined composition

After a Shift tap, letters, digits and word punctuation go straight to the
app instead of into marked text, so nothing is underlined. Space, Enter, Tab,
Escape or another symbol ends the forced word and automatic detection
resumes; backspace is handled by the app.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 11:35:59 +08:00
co-authored by Claude Opus 5.5
parent 82f20a6551
commit e928d08fdc
6 changed files with 101 additions and 12 deletions
+20
View File
@@ -267,5 +267,25 @@ class CursorTests(unittest.TestCase):
self.assertTrue(e.showing_candidates)
class DirectEnglishTests(unittest.TestCase):
def test_forced_english_has_no_composition(self):
e = make_engine()
e.handle(SHIFT_TAP)
self.assertEqual(e.handle("r"), (True, "r"))
self.assertEqual(e.marked_text, "")
self.assertEqual(e.handle("'"), (True, "'"))
self.assertEqual(e.handle(BACKSPACE), (False, None))
self.assertTrue(e.english_armed)
self.assertEqual(e.handle(" "), (True, " "))
self.assertFalse(e.english_armed)
def test_enter_ends_forced_english(self):
e = make_engine()
e.handle(SHIFT_TAP)
e.handle("a")
self.assertEqual(e.handle(ENTER), (False, None))
self.assertFalse(e.english_armed)
if __name__ == "__main__":
unittest.main()