Stop the cursor after the first Chinese character

Moving left no longer reaches the start of the buffer (or any position before the
first Zhuyin syllable), where there is nothing to pick candidates for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 15:30:03 +08:00
co-authored by Claude Opus 5.5
parent 6448bf4ca2
commit fa5b266ae4
5 changed files with 36 additions and 17 deletions
@@ -384,7 +384,7 @@ final class CursorTests: XCTestCase {
_ = type("←", into: e)
XCTAssertEqual(e.cursorOffset, 3)
_ = type("←←←←", into: e)
XCTAssertEqual(e.cursorOffset, 0) // stops at the start
XCTAssertEqual(e.cursorOffset, 1) // stops after the first character
_ = type("→→→→", into: e)
XCTAssertEqual(e.cursorOffset, 4)
}
@@ -419,8 +419,10 @@ final class CursorTests: XCTestCase {
XCTAssertEqual(type("\n", into: e), "今天氣")
}
func testInsertAtStart() {
XCTAssertEqual(type("su3cl3←←ji3\n", into: engine()), "我你好")
func testCursorStopsAfterFirstCharacter() {
let e = engine()
_ = type("su3cl3←←←", into: e)
XCTAssertEqual(e.cursorOffset, 1)
}
func testBackspaceDeletesCharacterBeforeCursor() {