Skip to content

Commit 71db68f

Browse files
committed
Fix context display fallback for single furigana segment
1 parent 5d68d43 commit 71db68f

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

MaruDictionaryUICommon/ContextDisplayView.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ struct ContextDisplayView: View {
7474
baseFontSize + furiganaFontSize + furiganaSpacing
7575
}
7676

77+
private var shouldUsePlainTextLayout: Bool {
78+
guard let segment = furiganaSegments.first else { return true }
79+
80+
return furiganaSegments.count == 1
81+
&& segment.reading == nil
82+
&& segment.base == context
83+
&& segment.baseRange.lowerBound == context.startIndex
84+
&& segment.baseRange.upperBound == context.endIndex
85+
}
86+
7787
private var themedBackgroundColor: Color {
7888
presentationTheme?.backgroundColor ?? Color(.systemBackground)
7989
}
@@ -178,10 +188,10 @@ struct ContextDisplayView: View {
178188

179189
@ViewBuilder
180190
private func contextTextContent(width: CGFloat) -> some View {
181-
if !furiganaSegments.isEmpty {
182-
segmentedTextView(width: width)
183-
} else {
191+
if shouldUsePlainTextLayout {
184192
plainTextView(width: width)
193+
} else {
194+
segmentedTextView(width: width)
185195
}
186196
}
187197

0 commit comments

Comments
 (0)