- Open macOS TextEdit application
- enter "aaaaaaaaaaaaaaaaaaaa"
- move insertion point at location 0
- switch system keyboard to Pinyin - Simplified (Chinese)
- on the keyboard type letters "abcdefghij"
- 💥 observe bug: marked text is "abc " insertion point is at location 11
expected: insertion point is at location 4
The problem is observable from setMarkedText(_:selectedRange:replacementRange:)
from NSTextInputClient protocol, where selectedRange value changes from 16 to 11 without a good reason:
logs:
setMarkedText(_:selectedRange:replacementRange:) a bc de fghi, selectedRange: (16, 0), replacementRange: 19223372036854775807, 0,
setMarkedText(_:selectedRange:replacementRange:) abc, selectedRange: {11, 0}, replacementRange: {9223372036854775807, 0}