Fixes a crash on adding user phrases.

This commit is contained in:
zonble 2022-02-01 08:41:36 +08:00
parent 347560e36b
commit 82dbed7815
1 changed files with 3 additions and 2 deletions

View File

@ -222,8 +222,9 @@ class InputState: NSObject {
@objc var userPhrase: String {
let text = (composingBuffer as NSString).substring(with: markedRange)
let end = markedRange.location + markedRange.length
let readings = readings[markedRange.location..<end]
let exactBegin = StringUtils.convertToCharIndex(from: markedRange.location, in: composingBuffer)
let exactEnd = StringUtils.convertToCharIndex(from: markedRange.location + markedRange.length, in: composingBuffer)
let readings = readings[exactBegin..<exactEnd]
let joined = readings.joined(separator: "-")
return "\(text) \(joined)"
}