SessionCtl // Add one more replacement attempt to the final commit.
This commit is contained in:
parent
3a8060bf88
commit
16750e4bde
|
@ -233,6 +233,11 @@ public extension vChewingLM {
|
||||||
lmAssociates.valuesFor(pair: pair)
|
lmAssociates.valuesFor(pair: pair)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func queryReplacementValue(key: String) -> String? {
|
||||||
|
let result = lmReplacements.valuesFor(key: key)
|
||||||
|
return result.isEmpty ? nil : result
|
||||||
|
}
|
||||||
|
|
||||||
/// 插入臨時資料。
|
/// 插入臨時資料。
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - key: 索引鍵陣列。
|
/// - key: 索引鍵陣列。
|
||||||
|
|
|
@ -129,8 +129,17 @@ public extension SessionCtl {
|
||||||
/// 遞交組字區內容。
|
/// 遞交組字區內容。
|
||||||
/// 注意:必須在 IMK 的 commitComposition 函式當中也間接或者直接執行這個處理。
|
/// 注意:必須在 IMK 的 commitComposition 函式當中也間接或者直接執行這個處理。
|
||||||
private func commit(text: String) {
|
private func commit(text: String) {
|
||||||
let text = text.trimmingCharacters(in: .newlines)
|
let phE = PrefMgr.shared.phraseReplacementEnabled && text.count > 1
|
||||||
let buffer = ChineseConverter.kanjiConversionIfRequired(text)
|
var text = text.trimmingCharacters(in: .newlines)
|
||||||
|
var replaced = false
|
||||||
|
if phE, let queried = inputHandler?.currentLM.queryReplacementValue(key: text) {
|
||||||
|
replaced = true
|
||||||
|
text = queried
|
||||||
|
}
|
||||||
|
var buffer = ChineseConverter.kanjiConversionIfRequired(text)
|
||||||
|
if phE, !replaced, let queried = inputHandler?.currentLM.queryReplacementValue(key: buffer) {
|
||||||
|
buffer = ChineseConverter.kanjiConversionIfRequired(queried)
|
||||||
|
}
|
||||||
if isServingIMEItself {
|
if isServingIMEItself {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
guard let client = self.client() else { return }
|
guard let client = self.client() else { return }
|
||||||
|
|
Loading…
Reference in New Issue