mirror of
https://github.com/mii443/AzooKeyKanaKanjiConverter.git
synced 2025-08-22 15:05:26 +00:00
fix: input kimi and then delete, you won't get any conversion result
This commit is contained in:
@ -44,18 +44,16 @@ extension Kana2Kanji {
|
||||
let latticeIndices = indexMap.indices(inputCount: inputCount, surfaceCount: surfaceCount)
|
||||
var lattice = previousResult.lattice.prefix(inputCount: commonInputCount, surfaceCount: commonSurfaceCount)
|
||||
|
||||
let terminalNodes: Lattice
|
||||
if counts.addedInput == 0 && counts.addedSurface == 0 {
|
||||
terminalNodes = Lattice(
|
||||
inputCount: inputCount,
|
||||
surfaceCount: surfaceCount,
|
||||
rawNodes: lattice.map {
|
||||
$0.filter {
|
||||
$0.range.endIndex == .input(inputCount) || $0.range.endIndex == .surface(inputCount)
|
||||
}
|
||||
var terminalNodes = Lattice(
|
||||
inputCount: inputCount,
|
||||
surfaceCount: surfaceCount,
|
||||
rawNodes: lattice.map {
|
||||
$0.filter {
|
||||
$0.range.endIndex == .input(inputCount) || $0.range.endIndex == .surface(surfaceCount)
|
||||
}
|
||||
)
|
||||
} else {
|
||||
}
|
||||
)
|
||||
if !(counts.addedInput == 0 && counts.addedSurface == 0) {
|
||||
// (2)
|
||||
let rawNodes = latticeIndices.map { index in
|
||||
let inputRange: (startIndex: Int, endIndexRange: Range<Int>?)? = if let iIndex = index.inputIndex, max(commonInputCount, iIndex) < inputCount {
|
||||
@ -80,7 +78,6 @@ extension Kana2Kanji {
|
||||
surfaceCount: surfaceCount,
|
||||
rawNodes: rawNodes
|
||||
)
|
||||
|
||||
// (3)
|
||||
for nodeArray in lattice {
|
||||
for node in nodeArray {
|
||||
@ -98,7 +95,7 @@ extension Kana2Kanji {
|
||||
}
|
||||
}
|
||||
lattice.merge(addedNodes)
|
||||
terminalNodes = addedNodes
|
||||
terminalNodes.merge(addedNodes)
|
||||
}
|
||||
|
||||
// (3)
|
||||
|
@ -131,6 +131,29 @@ final class ConverterTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
// memo: このケースで単漢字変換などの結果が得られない問題があった
|
||||
func testKimiAndThenDelete() async throws {
|
||||
let converter = await KanaKanjiConverter()
|
||||
var c = ComposingText()
|
||||
let text = "kimi"
|
||||
// 許容される変換結果
|
||||
let possibles = [
|
||||
"君",
|
||||
"気味",
|
||||
"黄身"
|
||||
]
|
||||
for char in text {
|
||||
c.insertAtCursorPosition(String(char), inputStyle: .roman2kana)
|
||||
let results = await converter.requestCandidates(c, options: requestOptions())
|
||||
if c.input.count == text.count {
|
||||
XCTAssertTrue(possibles.contains(results.mainResults.first!.text))
|
||||
}
|
||||
}
|
||||
// 1文字削除
|
||||
c.deleteBackwardFromCursorPosition(count: 1)
|
||||
let results = await converter.requestCandidates(c, options: requestOptions())
|
||||
XCTAssertTrue(results.mainResults.contains { $0.text == "黄" })
|
||||
}
|
||||
|
||||
// memo: このケースでfatalErrorが発生する不具合が生じることがあった
|
||||
func testIttaAndThenDelete() async throws {
|
||||
|
Reference in New Issue
Block a user