From 7ddd658156d9b49a6ee674c7aa82f00547acf36b Mon Sep 17 00:00:00 2001 From: Miwa / Ensan Date: Tue, 3 Mar 2026 00:24:45 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=88=E3=83=AA=E3=82=AC=E3=83=BC?= =?UTF-8?q?=E3=81=8C=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/InputUtils/SegmentsManager.swift | 21 ------------- ...erPredictionBackspaceCorrectionTests.swift | 30 ------------------- 2 files changed, 51 deletions(-) diff --git a/Core/Sources/Core/InputUtils/SegmentsManager.swift b/Core/Sources/Core/InputUtils/SegmentsManager.swift index 461523b..4e2bd16 100644 --- a/Core/Sources/Core/InputUtils/SegmentsManager.swift +++ b/Core/Sources/Core/InputUtils/SegmentsManager.swift @@ -371,17 +371,6 @@ public final class SegmentsManager { } return } - let currentBestCandidateText = self.rawCandidates?.mainResults.first?.text ?? self.rawCandidatesList?.first?.text - let shouldTriggerTypoCorrection = Self.shouldTriggerBackspaceTypoCorrection( - deleteCount: count, - currentBestCandidateText: currentBestCandidateText, - currentInput: currentInput - ) - guard shouldTriggerTypoCorrection else { - self.backspaceAdjustedPredictionCandidate = nil - self.backspaceTypoCorrectionLock = nil - return - } self.backspaceTypoCorrectionLock = self.lmBasedBackspaceTypoCorrectionLock(previousComposingText: beforeComposingText) if let lock = self.backspaceTypoCorrectionLock { self.backspaceAdjustedPredictionCandidate = Self.makeBackspaceTypoCorrectionPredictionCandidate( @@ -953,16 +942,6 @@ public final class SegmentsManager { return .init(displayText: displayText, appendText: operation.appendText, deleteCount: operation.deleteCount) } - static func shouldTriggerBackspaceTypoCorrection(deleteCount: Int, currentBestCandidateText: String?, currentInput: String) -> Bool { - guard deleteCount == 1 else { - return false - } - if let currentBestCandidateText, currentBestCandidateText == currentInput { - return false - } - return true - } - private static func makeSuffixEditOperation(from currentText: String, to targetText: String) -> (appendText: String, deleteCount: Int)? { let sharedPrefixLength = zip(currentText, targetText).prefix(while: ==).count let deleteCount = currentText.count - sharedPrefixLength diff --git a/Core/Tests/CoreTests/InputUtilsTests/SegmentsManagerPredictionBackspaceCorrectionTests.swift b/Core/Tests/CoreTests/InputUtilsTests/SegmentsManagerPredictionBackspaceCorrectionTests.swift index 53629b5..6fea7c7 100644 --- a/Core/Tests/CoreTests/InputUtilsTests/SegmentsManagerPredictionBackspaceCorrectionTests.swift +++ b/Core/Tests/CoreTests/InputUtilsTests/SegmentsManagerPredictionBackspaceCorrectionTests.swift @@ -1,36 +1,6 @@ @testable import Core import Testing -@Test func testShouldTriggerBackspaceTypoCorrectionReturnsFalseWhenBestCandidateMatchesCurrentInput() async throws { - let shouldTrigger = SegmentsManager.shouldTriggerBackspaceTypoCorrection( - deleteCount: 1, - currentBestCandidateText: "くだし", - currentInput: "くだし" - ) - - #expect(shouldTrigger == false) -} - -@Test func testShouldTriggerBackspaceTypoCorrectionReturnsTrueWhenBestCandidateDiffersFromCurrentInput() async throws { - let shouldTrigger = SegmentsManager.shouldTriggerBackspaceTypoCorrection( - deleteCount: 1, - currentBestCandidateText: "下さい", - currentInput: "くだし" - ) - - #expect(shouldTrigger == true) -} - -@Test func testShouldTriggerBackspaceTypoCorrectionReturnsFalseWhenDeleteCountIsNotOne() async throws { - let shouldTrigger = SegmentsManager.shouldTriggerBackspaceTypoCorrection( - deleteCount: 2, - currentBestCandidateText: "下さい", - currentInput: "くだし" - ) - - #expect(shouldTrigger == false) -} - @Test func testMakeBackspaceTypoCorrectionPredictionCandidateRecalculatesEditOperationForCurrentInput() async throws { let candidate = SegmentsManager.makeBackspaceTypoCorrectionPredictionCandidate( currentInput: "くだし",