Skip to content

Commit 7ddd658

Browse files
committed
fix: トリガーがされない問題を修正
1 parent 34b545d commit 7ddd658

2 files changed

Lines changed: 0 additions & 51 deletions

File tree

Core/Sources/Core/InputUtils/SegmentsManager.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,6 @@ public final class SegmentsManager {
371371
}
372372
return
373373
}
374-
let currentBestCandidateText = self.rawCandidates?.mainResults.first?.text ?? self.rawCandidatesList?.first?.text
375-
let shouldTriggerTypoCorrection = Self.shouldTriggerBackspaceTypoCorrection(
376-
deleteCount: count,
377-
currentBestCandidateText: currentBestCandidateText,
378-
currentInput: currentInput
379-
)
380-
guard shouldTriggerTypoCorrection else {
381-
self.backspaceAdjustedPredictionCandidate = nil
382-
self.backspaceTypoCorrectionLock = nil
383-
return
384-
}
385374
self.backspaceTypoCorrectionLock = self.lmBasedBackspaceTypoCorrectionLock(previousComposingText: beforeComposingText)
386375
if let lock = self.backspaceTypoCorrectionLock {
387376
self.backspaceAdjustedPredictionCandidate = Self.makeBackspaceTypoCorrectionPredictionCandidate(
@@ -953,16 +942,6 @@ public final class SegmentsManager {
953942
return .init(displayText: displayText, appendText: operation.appendText, deleteCount: operation.deleteCount)
954943
}
955944

956-
static func shouldTriggerBackspaceTypoCorrection(deleteCount: Int, currentBestCandidateText: String?, currentInput: String) -> Bool {
957-
guard deleteCount == 1 else {
958-
return false
959-
}
960-
if let currentBestCandidateText, currentBestCandidateText == currentInput {
961-
return false
962-
}
963-
return true
964-
}
965-
966945
private static func makeSuffixEditOperation(from currentText: String, to targetText: String) -> (appendText: String, deleteCount: Int)? {
967946
let sharedPrefixLength = zip(currentText, targetText).prefix(while: ==).count
968947
let deleteCount = currentText.count - sharedPrefixLength

Core/Tests/CoreTests/InputUtilsTests/SegmentsManagerPredictionBackspaceCorrectionTests.swift

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,6 @@
11
@testable import Core
22
import Testing
33

4-
@Test func testShouldTriggerBackspaceTypoCorrectionReturnsFalseWhenBestCandidateMatchesCurrentInput() async throws {
5-
let shouldTrigger = SegmentsManager.shouldTriggerBackspaceTypoCorrection(
6-
deleteCount: 1,
7-
currentBestCandidateText: "くだし",
8-
currentInput: "くだし"
9-
)
10-
11-
#expect(shouldTrigger == false)
12-
}
13-
14-
@Test func testShouldTriggerBackspaceTypoCorrectionReturnsTrueWhenBestCandidateDiffersFromCurrentInput() async throws {
15-
let shouldTrigger = SegmentsManager.shouldTriggerBackspaceTypoCorrection(
16-
deleteCount: 1,
17-
currentBestCandidateText: "下さい",
18-
currentInput: "くだし"
19-
)
20-
21-
#expect(shouldTrigger == true)
22-
}
23-
24-
@Test func testShouldTriggerBackspaceTypoCorrectionReturnsFalseWhenDeleteCountIsNotOne() async throws {
25-
let shouldTrigger = SegmentsManager.shouldTriggerBackspaceTypoCorrection(
26-
deleteCount: 2,
27-
currentBestCandidateText: "下さい",
28-
currentInput: "くだし"
29-
)
30-
31-
#expect(shouldTrigger == false)
32-
}
33-
344
@Test func testMakeBackspaceTypoCorrectionPredictionCandidateRecalculatesEditOperationForCurrentInput() async throws {
355
let candidate = SegmentsManager.makeBackspaceTypoCorrectionPredictionCandidate(
366
currentInput: "くだし",

0 commit comments

Comments
 (0)