Skip to content

Commit 9ce87b0

Browse files
authored
fix: ComposingCount同士を比較することで発生するエラーに対処 (#175)
1 parent ff08268 commit 9ce87b0

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

azooKeyMac/InputController/SegmentsManager.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ final class SegmentsManager {
258258
private var candidates: [Candidate]? {
259259
if let rawCandidates {
260260
if !self.didExperienceSegmentEdition {
261-
if rawCandidates.firstClauseResults.contains(where: { $0.composingCount == .surfaceCount(self.composingText.convertTarget.count) || $0.composingCount == .inputCount(self.composingText.input.count) }) {
261+
if rawCandidates.firstClauseResults.contains(where: { self.composingText.isWholeComposingText(composingCount: $0.composingCount) }) {
262262
// firstClauseCandidateがmainResultsと同じサイズの場合は、何もしない方が良い
263263
return rawCandidates.mainResults
264264
} else {
@@ -522,7 +522,8 @@ final class SegmentsManager {
522522
}
523523
return MarkedText(text: [.init(content: text, focus: .none)], selectionRange: .notFound)
524524
case .previewing:
525-
if let fullCandidate = self.rawCandidates?.mainResults.first, fullCandidate.composingCount == .inputCount(self.composingText.input.count) || fullCandidate.composingCount == .surfaceCount(self.composingText.convertTarget.count) {
525+
if let fullCandidate = self.rawCandidates?.mainResults.first,
526+
self.composingText.isWholeComposingText(composingCount: fullCandidate.composingCount) {
526527
return MarkedText(text: [.init(content: fullCandidate.text, focus: .none)], selectionRange: .notFound)
527528
} else {
528529
return MarkedText(text: [.init(content: self.composingText.convertTarget, focus: .none)], selectionRange: .notFound)
@@ -563,3 +564,11 @@ final class SegmentsManager {
563564
protocol SegmentManagerDelegate: AnyObject {
564565
func getLeftSideContext(maxCount: Int) -> String?
565566
}
567+
568+
private extension ComposingText {
569+
func isWholeComposingText(composingCount: ComposingCount) -> Bool {
570+
var c = self
571+
c.prefixComplete(composingCount: composingCount)
572+
return c.isEmpty
573+
}
574+
}

0 commit comments

Comments
 (0)