From addbda6f17d14aa54dae22dbca6111c3bf9efc85 Mon Sep 17 00:00:00 2001 From: SHIINA Hideaki Date: Wed, 2 Sep 2026 10:23:09 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BA=88=E6=B8=AC=E5=80=99=E8=A3=9C?= =?UTF-8?q?=E3=82=92=20Tab=20=E3=81=A7=E5=8F=97=E3=81=91=E5=85=A5=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E3=81=93=E3=81=A8=E3=82=92AzooKeyKanaKanjiConverter?= =?UTF-8?q?=E3=81=AB=E4=BC=9D=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConverterServer/ConverterServer+KeyEvent.swift | 4 ++++ Core/Sources/Core/InputUtils/SegmentsManager.swift | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Core/Sources/ConverterServer/ConverterServer+KeyEvent.swift b/Core/Sources/ConverterServer/ConverterServer+KeyEvent.swift index 56cba218..b4837ce2 100644 --- a/Core/Sources/ConverterServer/ConverterServer+KeyEvent.swift +++ b/Core/Sources/ConverterServer/ConverterServer+KeyEvent.swift @@ -373,6 +373,10 @@ extension ConverterServer { guard !prediction.appendText.isEmpty else { return } + if let candidate = prediction.candidate { + // 読みを補完する前に伝える。補完後の再変換で候補の表記が先頭の制約になる + manager.acceptPredictionCandidate(candidate) + } manager.insertAtCursorPosition(prediction.appendText, inputStyle: .direct) } } diff --git a/Core/Sources/Core/InputUtils/SegmentsManager.swift b/Core/Sources/Core/InputUtils/SegmentsManager.swift index 3188ca36..5cb442ee 100644 --- a/Core/Sources/Core/InputUtils/SegmentsManager.swift +++ b/Core/Sources/Core/InputUtils/SegmentsManager.swift @@ -65,6 +65,8 @@ public final class SegmentsManager { public var displayText: String public var appendText: String public var deleteCount: Int = 0 + /// 表示のもとになった変換器の候補。受け入れたことを変換器へ伝えるのに使う + public var candidate: Candidate? } struct BackspaceTypoCorrectionLock: Sendable { @@ -861,6 +863,11 @@ public final class SegmentsManager { return [backspaceAdjustedPredictionCandidate] } + /// 予測候補を受け入れたことを変換器へ伝える。以降の変換では、その候補の表記が先頭の制約になる + public func acceptPredictionCandidate(_ candidate: Candidate) { + self.kanaKanjiConverter.setPrefixCandidate(candidate) + } + public static func preferredPredictionCandidates( typoCorrectionCandidates: [PredictionCandidate], predictionCandidates: [PredictionCandidate] @@ -898,11 +905,12 @@ public final class SegmentsManager { guard !reading.isEmpty else { continue } - if let predictionCandidate = Self.makePredictionCandidate( + if var predictionCandidate = Self.makePredictionCandidate( currentTarget: target, candidateReading: reading, displayText: candidate.text ) { + predictionCandidate.candidate = candidate return [predictionCandidate] } }